Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A409E9578 for ; Fri, 27 Apr 2012 14:16:21 +0000 (UTC) Received: (qmail 97548 invoked by uid 500); 27 Apr 2012 14:16:21 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 97519 invoked by uid 500); 27 Apr 2012 14:16:21 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 97511 invoked by uid 99); 27 Apr 2012 14:16:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2012 14:16:21 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=LOTS_OF_MONEY,RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [198.240.130.132] (HELO mail-gw28.credit-suisse.com) (198.240.130.132) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2012 14:16:14 +0000 Received: by mail-gw28.credit-suisse.com; Fri, 27 Apr 2012 14:15:50 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: RE: JMS Endpoint Reuse and sending to different destinations @ Runtime Date: Fri, 27 Apr 2012 10:15:47 -0400 Message-ID: In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: JMS Endpoint Reuse and sending to different destinations @ Runtime thread-index: Ac0kOsSdEdMMCnBBSAexRTGV3Fl45AAQ3fwA References: From: "Gershaw, Geoffrey" To: X-OriginalArrivalTime: 27 Apr 2012 14:15:48.0391 (UTC) FILETIME=[3E56EB70:01CD2480] Hi Claus, Thanks again for your help. Please see below/ // Works with this code //I just add the destination header to the In Message. Let camel handle the= next steps =09public void publish(Exchange exchange){ =09=09Publishable publishable=3D exchange.getIn().getBody(Publishable.class= ); =09=09Map origMsgHeaders =3D publishable.getPublishPropertie= s(); =09=09Map msgHeaders =3D new HashMap(origMsg= Headers); =09=09String destinationName =3D null; =09=09if(!StringUtils.isEmpty(destinationPrefix)){ =09=09=09destinationName =3D String.format("%s.%s", destinationPrefix, publ= ishable.getPublishTopicName()); =09=09}else{ =09=09=09destinationName =3D publishable.getPublishTopicName(); =09=09} =09=09if(log.isDebugEnabled()){ =09=09=09log.debug("Destination is " + destinationName); =09=09} =09=09exchange.getIn().setHeader(JmsConstants.JMS_DESTINATION_NAME, destina= tionName); =09} Good Logs: On the last line I can see where the component is sending 10:11:40,203 [QFJ Message Processor] DEBUG com.csfb.oddlots.creditex.md.Gen= ericCamelPublisher - Destination is T.NY.COLT.FBID.REDC.2I65BYCO1 10:11:40,205 [QFJ Message Processor] DEBUG org.apache.camel.processor.SendP= rocessor - >>>> Endpoint[jmsUS://topic:dummy] Exchange[.....Removed for br= evity ]] 10:11:40,372 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.J= msConfiguration$CamelJmsTemplate - Executing callback on JMS Session: com.= tibco.tibjms.TibjmsxSessionImp@f1c18 10:11:40,398 [QFJ Message Processor] WARN org.apache.camel.component.jms.J= msBinding - Cannot determine specific JmsMessage type to use from body cla= ss. Will use generic JmsMessage. Body class: com.csfb.oddlots.model.MarketD= ata. If you want to send a POJO then your class might need to implement jav= a.io.Serializable, or you can force a specific type by setting the jmsMessa= geType option on the JMS endpoint. 10:11:40,399 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.J= msBinding - Ignoring non primitive header: EventCategory of class: org.apa= che.camel.component.quickfixj.QuickfixjEventCategory with value: AppMessage= Received 10:11:40,399 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.J= msBinding - Ignoring non primitive header: SessionID of class: quickfix.Se= ssionID with value: FIX.4.2:CS_MD_FLOW1->CX 10:11:40,400 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.J= msConfiguration - Sending JMS message to: Topic[T.NY.COLT.FBID.REDC.2I65BY= CO1] with message: Header=3D{ JMSMessageID=3D{null} JMSDestination=3D{null= } JMSReplyTo=3D{null} JMSDeliveryMode=3D{PERSISTENT} JMSRedelivered=3D{fals= e} JMSCorrelationID=3D{null} JMSType=3D{null} JMSTimestamp=3D{0} JMSExpirat= ion=3D{0} JMSPriority=3D{4} } Properties=3D{ breadcrumbId=3D{String:ID-USD0= 9546426-55464-1335535888673-0-4233} MessageType=3D{String:W} } It won't work with this code. =09//Here I am setting adding the destination name to a Map of Headers =09//Using jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayl= oad(), msgHeaders); =09public void publish(Publishable publishable){ =09=09Map origMsgHeaders =3D publishable.getPublishPropertie= s(); =09=09Map msgHeaders =3D new HashMap(origMsg= Headers); =09=09String destinationName =3D null; =09=09if(!StringUtils.isEmpty(destinationPrefix)){ =09=09=09destinationName =3D String.format("%s.%s", destinationPrefix, publ= ishable.getPublishTopicName()); =09=09}else{ =09=09=09destinationName =3D publishable.getPublishTopicName(); =09=09} =09=09if(log.isDebugEnabled()){ =09=09=09log.debug("Destination is " + destinationName); =09=09} =09=09msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName); =09=09jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayload(),= msgHeaders); =09} Bad Logs: I can't see where the Component is sending. I'm thinking you can'= t use ProducerTemplate with DestinationName as Header? Is that possible? 09:58:40,975 [QFJ Message Processor] DEBUG org.apache.camel.component.bean.= BeanProcessor - Setting bean invocation result on the OUT message: Removed= for brevity 09:58:40,975 [QFJ Message Processor] DEBUG com.csfb.oddlots.creditex.md.Gen= ericCamelPublisher - Destination is T.NY.COLT.FBID.REDC.2I65BYCO1 9:58:41,106 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.Jm= sConfiguration$CamelJmsTemplate - Executing callback on JMS Session: om.ti= bco.tibjms.TibjmsxSessionImp@db89c2 09:58:41,151 [QFJ Message Processor] WARN org.apache.camel.processor.UnitO= fWorkProcessor - Caught unhandled exception while processing ExchangeId: I= D-USD09546426-55398-1335535108913-0-4246 org.springframework.jms.InvalidDes= tinationException: Not allowed to create destination; nested exception is j= avax.jms.InvalidDestinationException: Not allowed to create destination -----Original Message----- From: Claus Ibsen [mailto:claus.ibsen@gmail.com]=20 Sent: Friday, April 27, 2012 1:58 AM To: users@camel.apache.org Subject: Re: JMS Endpoint Reuse and sending to different destinations @ Run= time On Thu, Apr 26, 2012 at 11:02 PM, Gershaw, Geoffrey wrote: > Hi Claus, > > Thanks for the reply. I agree there is a permissions issue on the JMS Bro= ker. The problem is that I can't see in the logs the name of the topic wher= e I'm publishing. > Well thats maybe because Camel dont reach so far that it tries to send the message, but the JMS Client fails beforehand with that permission error. It ought to be the client that reported a better exception message with the destination name. Well it reminds me of Oracle's exception with "Table or view does not exist= ". Camel has the logging it offers if you enable TRACE or DEBUG logging on the org.apache.camel.component.jms package. > I am using the ProducerTemplate > =A0msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName); > =A0jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayload(), = msgHeaders); > > I can see the value of destinationName in the below log line > 15:03:46,115 [QFJ Message Processor] DEBUG com.csfb.oddlots.creditex.md.G= enericCamelPublisher =A0- Destination is =A0T.NY.COLT.FBID.REDC.2I65BYCO1 > > But it looks like ultimately its trying to send jmsUS://topic > > 15:03:46,117 [QFJ Message Processor] DEBUG =A0org.apache.camel.impl.Produ= cerCache =A0- Adding to producer cache with =A0key: Endpoint[jmsUS://topic]= for producer: Producer[jmsUS://topic] > 15:03:46,120 [QFJ Message Processor] DEBUG org.apache.camel.impl.Producer= Cache =A0- >>>> Endpoint[jmsUS://topic] Exchange[Message:8=3DFIXT.1.19=3D17= 835=3DS15=3DUSD22=3DR48=3D2I65BYCO155=3D60200560=3D20120425-19:03:46.051117= =3D15648175132=3D95134=3D50000167=3DINDEX_CDS423=3D6537=3D1632=3D0647=3D063= 72=3DY7100=3DCX7101=3DUPD7102=3D156481757528=3D010=3D202] > > Any ideas? > > Thanks > > > -----Original Message----- > From: Claus Ibsen [mailto:claus.ibsen@gmail.com] > Sent: Thursday, April 26, 2012 3:20 AM > To: users@camel.apache.org > Subject: Re: JMS Endpoint Reuse and sending to different destinations @ R= untime > > Hi > > This seems like a permission/security setting. That your JMS broker > denies sending to non existing topics. >> javax.jms.InvalidDestinationException: Not allowed to create destination > > You may need to create the destination on the JMS broker using its > admin interface for that. > > > On Wed, Apr 25, 2012 at 9:11 PM, Gershaw, Geoffrey > wrote: >> Hello, >> >> >> >> I am trying to do what the subject of this mail says. I have looked at >> the documentation on the JMS component @ >> http://camel.apache.org/jms.html. >> >> >> >> I have a collection of Publishable objects. Publishable objects have >> >> >> >> 1. =A0 =A0 =A0 A method that returns the Topic name postfix. >> >> 2. =A0 =A0 =A0 A method that returns a Map of properties = to put >> as JMS Headers >> >> >> >> Based on what I read, I created the below class. I am using the >> ProducerTemplate to publish >> >> >> >> >> >> public class GenericCamelPublisher { >> >> =A0 =A0 =A0private ProducerTemplate jmsProducer; >> >> =A0 =A0 =A0private static final Logger log =3D >> Logger.getLogger(GenericCamelPublisher.class); >> >> =A0 =A0 =A0private String destinationPrefix; >> >> =A0 =A0 =A0private String endPointUri; >> >> >> >> =A0 =A0 =A0public GenericCamelPublisher(ProducerTemplate jmsProducer, St= ring >> destinationPrefix, String endPointUri){ >> >> =A0 =A0 =A0 =A0 =A0 =A0this.jmsProducer =3D jmsProducer; >> >> =A0 =A0 =A0 =A0 =A0 =A0this.destinationPrefix =3D destinationPrefix; >> >> =A0 =A0 =A0 =A0 =A0 =A0this.endPointUri =3D endPointUri; >> >> =A0 =A0 =A0} >> >> >> >> =A0 =A0 =A0public void publish(Publishable publishable){ >> >> =A0 =A0 =A0 =A0 =A0 =A0Map origMsgHeaders =3D >> publishable.getPublishProperties(); >> >> =A0 =A0 =A0 =A0 =A0 =A0Map msgHeaders =3D new HashMap> Object>(origMsgHeaders); >> >> =A0 =A0 =A0 =A0 =A0 =A0String destinationName =3D null; >> >> >> >> =A0 =A0 =A0 =A0 =A0 =A0if(!StringUtils.isEmpty(destinationPrefix)){ >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0destinationName =3D String.format("%s= .%s", >> destinationPrefix, publishable.getPublishTopicName()); >> >> =A0 =A0 =A0 =A0 =A0 =A0}else{ >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0destinationName =3D publishable.getPu= blishTopicName(); >> >> =A0 =A0 =A0 =A0 =A0 =A0} >> >> >> >> =A0 =A0 =A0 =A0 =A0 =A0if(log.isDebugEnabled()){ >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0log.debug("Destination is " + destina= tionName); >> >> =A0 =A0 =A0 =A0 =A0 =A0} >> >> =A0 =A0 =A0 =A0 =A0 =A0msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, >> destinationName); >> >> =A0 =A0 =A0 =A0 =A0 =A0jmsProducer.sendBodyAndHeaders(endPointUri, >> publishable.getPayload(), msgHeaders); >> >> =A0 =A0 =A0} >> >> } >> >> >> >> I receive the following output >> >> >> >> 15:03:46,115 [QFJ Message Processor] DEBUG >> com.csfb.oddlots.creditex.md.GenericCamelPublisher =A0- Destination is >> T.NY.COLT.FBID.REDC.2I65BYCO1 >> >> 15:03:46,115 [QFJ Message Processor] DEBUG >> org.apache.camel.impl.DefaultComponent =A0- Creating endpoint >> uri=3D[jmsUS://topic], path=3D[topic], parameters=3D[{}] >> >> 15:03:46,116 [QFJ Message Processor] DEBUG >> org.apache.camel.spring.SpringCamelContext =A0- jmsUS://topic converted = to >> endpoint: Endpoint[jmsUS://topic] by component: >> org.apache.camel.component.jms.JmsComponent@1d281f1 >> >> 15:03:46,117 [QFJ Message Processor] DEBUG >> org.apache.camel.component.jms.JmsProducer =A0- Starting producer: >> Producer[jmsUS://topic] >> >> 15:03:46,117 [QFJ Message Processor] DEBUG >> org.apache.camel.impl.ProducerCache =A0- Adding to producer cache with >> key: Endpoint[jmsUS://topic] for producer: Producer[jmsUS://topic] >> >> 15:03:46,120 [QFJ Message Processor] DEBUG >> org.apache.camel.impl.ProducerCache =A0- >>>> Endpoint[jmsUS://topic] >> Exchange[Message: >> 8=3DFIXT.1.19=3D17835=3DS15=3DUSD22=3DR48=3D2I65BYCO155=3D60200560=3D201= 20425-19:03:46.0 >> 51117=3D15648175132=3D95134=3D50000167=3DINDEX_CDS423=3D6537=3D1632=3D06= 47=3D06372=3DY7100 >> =3DCX7101=3DUPD7102=3D156481757528=3D010=3D202] >> >> 15:03:46,316 [QFJ Message Processor] DEBUG >> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate =A0- >> Executing callback on JMS Session: >> com.tibco.tibjms.TibjmsxSessionImp@1846149 >> >> 15:03:46,377 [QFJ Message Processor] WARN >> org.apache.camel.processor.UnitOfWorkProcessor =A0- Caught unhandled >> exception while processing ExchangeId: >> ID-USD09546426-64302-1335380610999-0-4234 >> >> org.springframework.jms.InvalidDestinationException: Not allowed to >> create destination; nested exception is >> javax.jms.InvalidDestinationException: Not allowed to create destination >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0at >> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt >> ils.java:285) >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0at >> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm >> sAccessor.java:168) >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0at >> org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:469) >> >> >> >> I have seen this exception if I try to publish to a topic that does not >> begin with T.NY.COLT. It's a permissioning thing. >> >> In this case, the logs don't tell where the jmsEndpoint tried to publish >> too. >> >> >> >> Am I approaching this the wrong way? >> >> >> >> Thanks in advance, >> >> >> Geoff >> >> >> >> >> >> >> >> Geoffrey A. Gershaw >> >> >> >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >> Please access the attached hyperlink for an important electronic communi= cations disclaimer: >> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >> > > > > -- > Claus Ibsen > ----------------- > CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com > FuseSource > Email: cibsen@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > Please access the attached hyperlink for an important electronic communic= ations disclaimer: > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > --=20 Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: cibsen@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=20 Please access the attached hyperlink for an important electronic communicat= ions disclaimer:=20 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=20