문제

my camel route is given below

 <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" >
    <route>
      <from uri="bean:SendClass?method=send" />
      <to uri="jms:MyQueue" pattern="InOnly" />
    </route>
    <route>
    <from uri="jms:MyQueue" />
    <to uri="bean:recvClass?method=recv" />
    </route>
  </camelContext>

The send method sends messages when activated by a 3rd party Pojo at some irregular intervals.But, the problem i think is camel is restarting the routes once the message is being received by recv bean and resending the same message (hundred's of them in a second ) .Ideally i want it to send the message when the send method gets activated and a new message has been created (i.e JMS Queue should be having unique message's).how do i do this ?

possible solutions being:

  1. is their some attribute which i can place inside the <from.../> to do this ?
  2. write a processor to filter unique message's between the send bean and the queue .
  3. Is their some other way of routing it without using the <from uri="bean:..." />

thanks sanre6

도움이 되었습니까?

해결책

You should not have the 1st route. When you do that you tell Camel to constantly invoke the send method on that bean and route it. And hence why you see 100s of messages per sec.

Instead you should use some Camel API from within your bean code and send the message to the JMS queue. For example using a ProducerTemplate.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top