14ํ JCO ๋ฐ๋ฃ์ ์ฌ์ฉ๋ ํ๋ก๊ทธ๋จ ์์ค์ ๋๋ค.
git clone https://github.com/hinunbi/jco-example.git
mvn compile
mvn camel:run
๋ณธ ํ๋ก์ ํธ๋ ํ ์คํธ๋ฅผ ์ํด ๋ณ๋์ ํด๋ผ์ด์ธํธ ํ๋ก๊ทธ๋จ์ ๊ฐ๋ฐํ์ง ์๊ณ ์น ์๋น์ค ํ ์คํธ ๊ฐ๋ฐ์ ๋๊ตฌ์ธ FireFox Poster ํ์ฅ์ ์ด์ฉํฉ๋๋ค.
HelloService๋ ์๋น์ค๊ฐ ์ ์์ ์ผ๋ก ๋์๋๋์ง๋ฅผ ํ์ธํ๋ ๊ธฐ๋ณธ ์น ์๋น์ค์ ๋๋ค.
- Firefox์์ Poster ํ์ ์ฐฝ์ ์คํํ ํ, ์ ๋ ฅ ํ๋์ ๋ค์๊ณผ ๊ฐ์ ์ ๋ณด๋ฅผ ์ ๋ ฅํ๊ณ POST ๋ฒํผ์ ๋๋ฆ ๋๋ค.
URL : http://localhost:8080/HelloService
Content Type : application/json
Content : {"name" : "ํ๊ธธ๋"}
- Poster ์๋ต์ด ๋ค์๊ณผ ๊ฐ์ผ๋ฉด ์น ์๋น์ค๊ฐ ์ ์์ ์ผ๋ก ๋์ํ ๊ฒ์ ๋๋ค.
{"status":"ServiceOk","reply":"Hello, ํ๊ธธ๋"}
TwitterService๋ ํธ์์ ์ ์กํ๋ ์น ์๋น์ค์ ๋๋ค.
-
TwitterService๋ฅผ ํ ์คํธ ํ๊ธฐ ์ํด์๋ ๋ฐ๋์ ๋ค์ ์ค๋น ์์ ์ด ํ ์คํธ ์ ์ ํ์ํฉ๋๋ค.
- ํธ์ํฐ ์น ์๋น์ค์์ ํธ์์ ์ฌ์ฉํ ํธ์ํฐ ์ ํ๋ฆฌ์ผ์ด์ ์ ํธ์ํฐ ๊ฐ๋ฐ์ ์ฌ์ดํธ์ ๋ฑ๋กํด์ผ ํฉ๋๋ค.
- ํธ์ํฐ ๊ฐ๋ฐ์ ์ฌ์ดํธ์์ ๋ฐ๊ธ๋ฐ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ณด๋ก camel-context.xml์ twitter ๋น์ ์์ฑ ๊ฐ๋ค์ ์์ ํด์ผ ํฉ๋๋ค.
- ๋ค์ ๋ถ๋ถ์ด camel-context.xml์์ ์์ ํด์ผ ํ ํธ์ํฐ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ ๋ณด์ ๋๋ค.
...
<bean id="twitter" class="org.apache.camel.component.twitter.TwitterComponent">
<property name="consumerKey" value="rsv2EAY6Zqq5ikm2tUmHg" />
<property name="consumerSecret" value="l2h8YOB1uEK7LJ8lIypPOJTMAjWfuAiO1k601hgKaTs" />
<property name="accessToken" value="548573273-yp6busuob3qVrd3nKSZi5XjEQa0pbLULoXNxguVd" />
<property name="accessTokenSecret" value="SpOEXlFIcZseVBeqitKsLjoCwArOYCZ65hhdi4G4x0" />
</bean>
...์ฃผ์) ์ ์์ฑ ๊ฐ๋ค๋ก๋ ํธ์ ํ ์คํธ๊ฐ ๋์ง ์์ต๋๋ค. ๋ฐ๋์ ๋ฐ๊ธ๋ฐ์ ์ ๋ณด๋ก ๋์ฒดํด์ผ ํฉ๋๋ค.
- Poster ์ ๋ ฅ ํ๋์ ๋ค์ ์ ๋ณด๋ฅผ ์ ๋ ฅํ๊ณ POST ๋ฒํผ์ ๋๋ฆ ๋๋ค.
URL : http://localhost:8080/TwitterService
Content Type : application/json
Content : {"tweet" : "ํธ์ ํ
์คํธ์
์ด๋ค."}
- Poster ์๋ต์ด ๋ค์๊ณผ ๊ฐ์ผ๋ฉด ํธ์ํฐ ์๋น์ค๊ฐ ์ ์์ ์ผ๋ก ๋์ํ ๊ฒ์ ๋๋ค.
{"status":"ServiceOk","reply":"Sent the tweet, [ํธ์ ํ
์คํธ์
์ด๋ค. at Thu Feb 20 11:28:05 KST 2014]"}
- ํธ์ํฐ ์ฑ์ด๋ ์น์์ ํธ์์ ํ์ธํฉ๋๋ค.
- ๊ธฐ์ ๋ฌธ์ : ๋ฐ๋ฅธ๋ชจ