You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by zuff <bh...@live.com> on 2012/08/06 10:52:18 UTC

Issue with temporary topic

Dear All,

   I'm facing some challenges with jmstemporarytopic.

   Overview of the system. A web-app (non-camel)  

   publish a JMS with the replyTo set as follows:

   TemoraryTopic replyTopic =
topicSubscriptionSession.createTemporaryTopic();
   .....
   objMsg.setJMSReplyTo(replyTopic );
 

   subscriber = topicSubscrierSession.createSubscriber(replyTopic);
   subscriber.setMessageListener(this);



_____________________________________________________________________________

At the recipient side:
    
    In a class that implements Processor

     A system.out.println of the exchange.getIn().getHeader() returns 
.................................JMSReplyTo=temp://ID:zuff-1931-1344239518234-35:1:1,
...........

   i)  I tried 
   TemporaryTopic topic = (TemporaryTopic)
exchange.getIn().getHeader("JMSReplyTo");
   JmsTemporaryTopicEndPoint jmsTempTopicEndPoint = new
JmsTemporaryTopicEndPoint (topic);
   template.sendBody( jmsTempTopicEndPoint , data );


   This will result in the following:
DefaultErrorHandler    ERROR     Failed Delivery for (MessageId: 
ID:zuff-1931-xx-yy:1:1:1:1 on ExchangeId: ID-zuff-xx-yy-0-2). Exhausted
after delivery attempts: 1 caught: 
org.apache.camel.FailedToCreateProducerException: Failed to create Producer
for endpoint: Endpoint[jms:temp:topic:ID:zuff-xx-yy-z:z].  Reason:
java.lang.NullPointerException 
      at  
org.apache.camel.impl.Proucercache.dogetProducer(ProducerCache.java:389)
[camel-core-2.10.0.jar:2.10.0]
......


   ii)  I also tried

   TemporaryTopic topic = (TemporaryTopic)
exchange.getIn().getHeader("JMSReplyTo");
   String tempUri = "jms:temp:topic:" + topic.getTopicName() );
   template.sendBody( tempUri , data );

    No exception was thrown from this, however, the webapp did not recieve
any messages.


   iii)   I also tried:

      TemporaryTopic topic = (TemporaryTopic)
exchange.getIn().getHeader("JMSReplyTo");      ...
      TopicPublisher publisher =
topicPublisherSession.createPublisher(topic);
      ObjectMessage objMsg = topicPublisherSession.createObjectMessage();
      objMsg .setObject( data ) ;

     publisher.publish( objMsg );

     This works. The webapps recieved the response. 

What am i doing wrong for the other 2 cases?
I read that for temporary topic, the same connection had to be used else the
topic will goes stale, but I do not fully understand what this means.

Thanks and Best Regards,
Zuff
 
  



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-temporary-topic-tp5716869.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with temporary topic

Posted by zuff <bh...@live.com>.
Hi Claus ,

   Thanks for the very prompt reply.

   I guess the header is already in the header, although i may have
misinterpret your message.

 part of my  route

   <route>
               <from uri="weblogic:topic:mytopic">
               <bean ref="mybean"/>     -> triggered some asynchronized call
which when completed will triggered a
template.sendBody(mycomponent:completed, obj); from another bean.
   </route>

   <route>
             <from uri="mycomponent:completed"/>
             <to uri="log:myclasspath/>
   </route>


__________________________________

public class RequestListener
{
      public void doIt( Exchange exchange,  Details details)
      {

                 ....
                 exchange.getOut().setBody(   dummyResult ) ;   --> if i do
this here, the temp topic works.
      }

}

_____________________________________
public class ProcessResult
{

      private ProducerTemplate template;

      public void sendComplete(Result result)
      {
                //Currently, I'm hardcoding the dynamic topic based on the
dynamic topic name generated before launching camel
                template.sendBody("weblogic:temp:topic:...", result);
      }

      ...
}


Best Regards,
Zuff



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-temporary-topic-tp5716869p5717492.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with temporary topic

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 16, 2012 at 9:22 AM, zuff <bh...@live.com> wrote:
> Hi,
>
>
>      I need some additional help. I now need to send a reply back without
> having access to the original Exchange, as the current scenario happened
> after some processing by an external source.
>
>
>     how do I send a reply back to the temp-topic if the temp topic name
> generated is something like
>
> ID:zuff-xxxxxxxxx-xxx-1:1:1
>

You may be able to specify the destination name in a header, see
section _Reuse endpoint and send to different destinations computed at
runtime_ at
http://camel.apache.org/jms

And then use sendBodyAndHeader on the producer template to pass in the
header as well.

The key for the header to use is: CamelJmsDestinationName


And mind that a temporary topic may not be visible when you sen the
message. To my understanding the temp topic/queue is only available in
memory and for the same JMSSession. But give it a try and see where
you are.

Also maybe you can configure the strategy how temporary names is
generated to avoid having colons and other chars.



> i tried with
> template.sendBody(weblogc://temp-topic:ID:zuff-xxxxxxxxx-xxx-1:1:1, myObj)
> without success.
> howver if i changed it to  template.sendBody(weblogc://topic:myTopic:ABC,
> myObj) it work.
>
> if the : causing some issue with the uri ?
>
> Best Regards,
> Zuff
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Issue-with-temporary-topic-tp5716869p5717477.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Issue with temporary topic

Posted by zuff <bh...@live.com>.
Hi, 


     I need some additional help. I now need to send a reply back without
having access to the original Exchange, as the current scenario happened
after some processing by an external source.


    how do I send a reply back to the temp-topic if the temp topic name
generated is something like  

ID:zuff-xxxxxxxxx-xxx-1:1:1

i tried with
template.sendBody(weblogc://temp-topic:ID:zuff-xxxxxxxxx-xxx-1:1:1, myObj) 
without success.
howver if i changed it to  template.sendBody(weblogc://topic:myTopic:ABC,
myObj) it work.

if the : causing some issue with the uri ?

Best Regards,
Zuff



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-temporary-topic-tp5716869p5717477.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with temporary topic

Posted by zuff <bh...@live.com>.
Thanks Ashwin,

     I managed to get it working after referencing the url you shared,
although I not sure whether I did it in the standard manner.  

    exchange.getOut.setBody(  myObj );

    Is the the suggested method since its different from the sample you had
shared, partially due to I don't have the from("") and to("") method as I'm
using a simple bean to perform the Processing.

Best Regards,
Zuff



--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-temporary-topic-tp5716869p5716906.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Issue with temporary topic

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

Please check out this link showing a JmsInOnlyWithReplyToAsHeaderTest
example

http://  
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToAsHeaderTest.java?view=markup
https://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToAsHeaderTest.java?view=markup 

This should get things sorted for you.

Cheers,

Ashwin...



-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Issue-with-temporary-topic-tp5716869p5716881.html
Sent from the Camel - Users mailing list archive at Nabble.com.