Skip to content

hinunbi/jco-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

100์ค„๋กœ ์™„์„ฑํ•˜๋Š” ์›น ์„œ๋น„์Šค ํ”Œ๋žซํผ

14ํšŒ JCO ๋ฐœ๋ฃŒ์— ์‚ฌ์šฉ๋œ ํ”„๋กœ๊ทธ๋žจ ์†Œ์Šค์ž…๋‹ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ ๋‹ค์šด๋กœ๋“œ

git clone https://github.com/hinunbi/jco-example.git

ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ

mvn compile

ํ”„๋กœ์ ํŠธ ์‹คํ–‰

mvn camel:run

ํ”„๋กœ์ ํŠธ ํ…Œ์ŠคํŠธ

๋ณธ ํ”„๋กœ์ ํŠธ๋Š” ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๋ณ„๋„์˜ ํด๋ผ์ด์–ธํŠธ ํ”„๋กœ๊ทธ๋žจ์„ ๊ฐœ๋ฐœํ•˜์ง€ ์•Š๊ณ  ์›น ์„œ๋น„์Šค ํ…Œ์ŠคํŠธ ๊ฐœ๋ฐœ์ž ๋„๊ตฌ์ธ FireFox Poster ํ™•์žฅ์„ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.

1. HelloService ํ…Œ์ŠคํŠธ

HelloService๋Š” ์„œ๋น„์Šค๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘๋˜๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ๊ธฐ๋ณธ ์›น ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค.

  1. Firefox์—์„œ Poster ํŒ์—…์ฐฝ์„ ์‹คํ–‰ํ•œ ํ›„, ์ž…๋ ฅ ํ•„๋“œ์— ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  POST ๋ฒ„ํŠผ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.
	URL : http://localhost:8080/HelloService  
	Content Type : application/json
	Content : {"name" : "ํ™๊ธธ๋™"}
  1. Poster ์‘๋‹ต์ด ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉด ์›น ์„œ๋น„์Šค๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
    {"status":"ServiceOk","reply":"Hello, ํ™๊ธธ๋™"}

2. TwitterService ํ…Œ์ŠคํŠธ

TwitterService๋Š” ํŠธ์œ—์„ ์ „์†กํ•˜๋Š” ์›น ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค.

  1. 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>
...

์ฃผ์˜) ์œ„ ์†์„ฑ ๊ฐ’๋“ค๋กœ๋Š” ํŠธ์œ— ํ…Œ์ŠคํŠธ๊ฐ€ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ฐ˜๋“œ์‹œ ๋ฐœ๊ธ‰๋ฐ›์€ ์ •๋ณด๋กœ ๋Œ€์ฒดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  1. Poster ์ž…๋ ฅ ํ•„๋“œ์— ๋‹ค์Œ ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•˜๊ณ  POST ๋ฒ„ํŠผ์„ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.
    URL : http://localhost:8080/TwitterService
    Content Type : application/json
    Content : {"tweet" : "ํŠธ์œ— ํ…Œ์ŠคํŠธ์ž…์ด๋‹ค."} 
  1. Poster ์‘๋‹ต์ด ๋‹ค์Œ๊ณผ ๊ฐ™์œผ๋ฉด ํŠธ์œ„ํ„ฐ ์„œ๋น„์Šค๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.
    {"status":"ServiceOk","reply":"Sent the tweet, [ํŠธ์œ— ํ…Œ์ŠคํŠธ์ž…์ด๋‹ค. at Thu Feb 20 11:28:05 KST 2014]"}
  1. ํŠธ์œ„ํ„ฐ ์•ฑ์ด๋‚˜ ์›น์—์„œ ํŠธ์œ—์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

์ฐธ๊ณ 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages