You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Gershaw, Geoffrey" <ge...@credit-suisse.com> on 2012/04/25 21:11:46 UTC

JMS Endpoint Reuse and sending to different destinations @ Runtime

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.       A method that returns the Topic name postfix. 

2.       A method that returns a Map<String,String> 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 {

      private ProducerTemplate jmsProducer;

      private static final Logger log =
Logger.getLogger(GenericCamelPublisher.class);

      private String destinationPrefix;

      private String endPointUri;

 

      public GenericCamelPublisher(ProducerTemplate jmsProducer, String
destinationPrefix, String endPointUri){

            this.jmsProducer = jmsProducer;

            this.destinationPrefix = destinationPrefix;

            this.endPointUri = endPointUri;

      }

 

      public void publish(Publishable publishable){

            Map<String,String> origMsgHeaders =
publishable.getPublishProperties();

            Map<String,Object> msgHeaders = new HashMap<String,
Object>(origMsgHeaders);

            String destinationName = null;

 

            if(!StringUtils.isEmpty(destinationPrefix)){

                  destinationName = String.format("%s.%s",
destinationPrefix, publishable.getPublishTopicName());

            }else{

                  destinationName = publishable.getPublishTopicName();

            }

 

            if(log.isDebugEnabled()){

                  log.debug("Destination is " + destinationName);

            }

            msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME,
destinationName);

            jmsProducer.sendBodyAndHeaders(endPointUri,
publishable.getPayload(), msgHeaders);

      }

}

 

I receive the following output

 

15:03:46,115 [QFJ Message Processor] DEBUG
com.csfb.oddlots.creditex.md.GenericCamelPublisher  - Destination is
T.NY.COLT.FBID.REDC.2I65BYCO1

15:03:46,115 [QFJ Message Processor] DEBUG
org.apache.camel.impl.DefaultComponent  - Creating endpoint
uri=[jmsUS://topic], path=[topic], parameters=[{}]

15:03:46,116 [QFJ Message Processor] DEBUG
org.apache.camel.spring.SpringCamelContext  - 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  - Starting producer:
Producer[jmsUS://topic]

15:03:46,117 [QFJ Message Processor] DEBUG
org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic]
Exchange[Message:
8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.0
51117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100
=CX7101=UPD7102=156481757528=010=202]

15:03:46,316 [QFJ Message Processor] DEBUG
org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  -
Executing callback on JMS Session:
com.tibco.tibjms.TibjmsxSessionImp@1846149

15:03:46,377 [QFJ Message Processor] WARN
org.apache.camel.processor.UnitOfWorkProcessor  - 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

                at
org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt
ils.java:285)

                at
org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm
sAccessor.java:168)

                at
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

 


=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 


Re: JMS Endpoint Reuse and sending to different destinations @ Runtime

Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Apr 27, 2012 at 4:15 PM, Gershaw, Geoffrey
<ge...@credit-suisse.com> wrote:
> 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
>
>        public void publish(Exchange exchange){
>                Publishable publishable= exchange.getIn().getBody(Publishable.class);
>                Map<String,String> origMsgHeaders = publishable.getPublishProperties();
>                Map<String,Object> msgHeaders = new HashMap<String, Object>(origMsgHeaders);
>                String destinationName = null;
>
>                if(!StringUtils.isEmpty(destinationPrefix)){
>                        destinationName = String.format("%s.%s", destinationPrefix, publishable.getPublishTopicName());
>                }else{
>                        destinationName = publishable.getPublishTopicName();
>                }
>
>                if(log.isDebugEnabled()){
>                        log.debug("Destination is " + destinationName);
>                }
>
>                exchange.getIn().setHeader(JmsConstants.JMS_DESTINATION_NAME, destinationName);
>        }
>
> 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.GenericCamelPublisher  - Destination is T.NY.COLT.FBID.REDC.2I65BYCO1
> 10:11:40,205 [QFJ Message Processor] DEBUG org.apache.camel.processor.SendProcessor  - >>>> Endpoint[jmsUS://topic:dummy] Exchange[.....Removed for brevity ]]
> 10:11:40,372 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  - Executing callback on JMS Session: com.tibco.tibjms.TibjmsxSessionImp@f1c18
> 10:11:40,398 [QFJ Message Processor] WARN  org.apache.camel.component.jms.JmsBinding  - Cannot determine specific JmsMessage type to use from body class. Will use generic JmsMessage. Body class: com.csfb.oddlots.model.MarketData. If you want to send a POJO then your class might need to implement java.io.Serializable, or you can force a specific type by setting the jmsMessageType option on the JMS endpoint.
> 10:11:40,399 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsBinding  - Ignoring non primitive header: EventCategory of class: org.apache.camel.component.quickfixj.QuickfixjEventCategory with value: AppMessageReceived
> 10:11:40,399 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsBinding  - Ignoring non primitive header: SessionID of class: quickfix.SessionID with value: FIX.4.2:CS_MD_FLOW1->CX
> 10:11:40,400 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsConfiguration  - Sending JMS message to: Topic[T.NY.COLT.FBID.REDC.2I65BYCO1] with message:  Header={ JMSMessageID={null} JMSDestination={null} JMSReplyTo={null} JMSDeliveryMode={PERSISTENT} JMSRedelivered={false} JMSCorrelationID={null} JMSType={null} JMSTimestamp={0} JMSExpiration={0} JMSPriority={4} } Properties={ breadcrumbId={String:ID-USD09546426-55464-1335535888673-0-4233} MessageType={String:W} }
>
>
>
> It won't work with this code.
>
>        //Here I am setting adding the destination name to a Map of Headers
>        //Using  jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayload(), msgHeaders);
>
>        public void publish(Publishable publishable){
>                Map<String,String> origMsgHeaders = publishable.getPublishProperties();
>                Map<String,Object> msgHeaders = new HashMap<String, Object>(origMsgHeaders);
>                String destinationName = null;
>
>                if(!StringUtils.isEmpty(destinationPrefix)){
>                        destinationName = String.format("%s.%s", destinationPrefix, publishable.getPublishTopicName());
>                }else{
>                        destinationName = publishable.getPublishTopicName();
>                }
>
>                if(log.isDebugEnabled()){
>                        log.debug("Destination is " + destinationName);
>                }
>                msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName);
>                jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayload(), msgHeaders);
>        }
>
>
> 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?
>

Yeah that should be possible, see the JmsProducer source code. It
would detect the headers first before falling back and using the
destination configured on the endpoint.

What version of Camel are you using?

>
> 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.GenericCamelPublisher  - Destination is T.NY.COLT.FBID.REDC.2I65BYCO1
> 9:58:41,106 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  - Executing callback on JMS Session: om.tibco.tibjms.TibjmsxSessionImp@db89c2
> 09:58:41,151 [QFJ Message Processor] WARN  org.apache.camel.processor.UnitOfWorkProcessor  - Caught unhandled exception while processing ExchangeId: ID-USD09546426-55398-1335535108913-0-4246 org.springframework.jms.InvalidDestinationException: Not allowed to create destination; nested exception is javax.jms.InvalidDestinationException: Not allowed to create destination
>
>
>
> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Friday, April 27, 2012 1:58 AM
> To: users@camel.apache.org
> Subject: Re: JMS Endpoint Reuse and sending to different destinations @ Runtime
>
> On Thu, Apr 26, 2012 at 11:02 PM, Gershaw, Geoffrey
> <ge...@credit-suisse.com> wrote:
>> Hi Claus,
>>
>> Thanks for the reply. I agree there is a permissions issue on the JMS Broker. The problem is that I can't see in the logs the name of the topic where 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
>>  msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName);
>>  jmsProducer.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.GenericCamelPublisher  - Destination is  T.NY.COLT.FBID.REDC.2I65BYCO1
>>
>> But it looks like ultimately its trying to send jmsUS://topic
>>
>> 15:03:46,117 [QFJ Message Processor] DEBUG  org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic] Exchange[Message:8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.051117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100=CX7101=UPD7102=156481757528=010=202]
>>
>> 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 @ Runtime
>>
>> 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
>> <ge...@credit-suisse.com> 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.       A method that returns the Topic name postfix.
>>>
>>> 2.       A method that returns a Map<String,String> 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 {
>>>
>>>      private ProducerTemplate jmsProducer;
>>>
>>>      private static final Logger log =
>>> Logger.getLogger(GenericCamelPublisher.class);
>>>
>>>      private String destinationPrefix;
>>>
>>>      private String endPointUri;
>>>
>>>
>>>
>>>      public GenericCamelPublisher(ProducerTemplate jmsProducer, String
>>> destinationPrefix, String endPointUri){
>>>
>>>            this.jmsProducer = jmsProducer;
>>>
>>>            this.destinationPrefix = destinationPrefix;
>>>
>>>            this.endPointUri = endPointUri;
>>>
>>>      }
>>>
>>>
>>>
>>>      public void publish(Publishable publishable){
>>>
>>>            Map<String,String> origMsgHeaders =
>>> publishable.getPublishProperties();
>>>
>>>            Map<String,Object> msgHeaders = new HashMap<String,
>>> Object>(origMsgHeaders);
>>>
>>>            String destinationName = null;
>>>
>>>
>>>
>>>            if(!StringUtils.isEmpty(destinationPrefix)){
>>>
>>>                  destinationName = String.format("%s.%s",
>>> destinationPrefix, publishable.getPublishTopicName());
>>>
>>>            }else{
>>>
>>>                  destinationName = publishable.getPublishTopicName();
>>>
>>>            }
>>>
>>>
>>>
>>>            if(log.isDebugEnabled()){
>>>
>>>                  log.debug("Destination is " + destinationName);
>>>
>>>            }
>>>
>>>            msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME,
>>> destinationName);
>>>
>>>            jmsProducer.sendBodyAndHeaders(endPointUri,
>>> publishable.getPayload(), msgHeaders);
>>>
>>>      }
>>>
>>> }
>>>
>>>
>>>
>>> I receive the following output
>>>
>>>
>>>
>>> 15:03:46,115 [QFJ Message Processor] DEBUG
>>> com.csfb.oddlots.creditex.md.GenericCamelPublisher  - Destination is
>>> T.NY.COLT.FBID.REDC.2I65BYCO1
>>>
>>> 15:03:46,115 [QFJ Message Processor] DEBUG
>>> org.apache.camel.impl.DefaultComponent  - Creating endpoint
>>> uri=[jmsUS://topic], path=[topic], parameters=[{}]
>>>
>>> 15:03:46,116 [QFJ Message Processor] DEBUG
>>> org.apache.camel.spring.SpringCamelContext  - 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  - Starting producer:
>>> Producer[jmsUS://topic]
>>>
>>> 15:03:46,117 [QFJ Message Processor] DEBUG
>>> org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic]
>>> Exchange[Message:
>>> 8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.0
>>> 51117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100
>>> =CX7101=UPD7102=156481757528=010=202]
>>>
>>> 15:03:46,316 [QFJ Message Processor] DEBUG
>>> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  -
>>> Executing callback on JMS Session:
>>> com.tibco.tibjms.TibjmsxSessionImp@1846149
>>>
>>> 15:03:46,377 [QFJ Message Processor] WARN
>>> org.apache.camel.processor.UnitOfWorkProcessor  - 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
>>>
>>>                at
>>> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt
>>> ils.java:285)
>>>
>>>                at
>>> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm
>>> sAccessor.java:168)
>>>
>>>                at
>>> 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
>>>
>>>
>>>
>>>
>>> ===============================================================================
>>> Please access the attached hyperlink for an important electronic communications disclaimer:
>>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>>> ===============================================================================
>>>
>>
>>
>>
>> --
>> 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/
>>
>> ===============================================================================
>> Please access the attached hyperlink for an important electronic communications disclaimer:
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>> ===============================================================================
>>
>
>
>
> --
> 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/
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
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/

RE: JMS Endpoint Reuse and sending to different destinations @ Runtime

Posted by "Gershaw, Geoffrey" <ge...@credit-suisse.com>.
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

	public void publish(Exchange exchange){
		Publishable publishable= exchange.getIn().getBody(Publishable.class);
		Map<String,String> origMsgHeaders = publishable.getPublishProperties();
		Map<String,Object> msgHeaders = new HashMap<String, Object>(origMsgHeaders);
		String destinationName = null;

		if(!StringUtils.isEmpty(destinationPrefix)){
			destinationName = String.format("%s.%s", destinationPrefix, publishable.getPublishTopicName());
		}else{
			destinationName = publishable.getPublishTopicName();
		}

		if(log.isDebugEnabled()){
			log.debug("Destination is " + destinationName);
		}

		exchange.getIn().setHeader(JmsConstants.JMS_DESTINATION_NAME, destinationName);
	}

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.GenericCamelPublisher  - Destination is T.NY.COLT.FBID.REDC.2I65BYCO1
10:11:40,205 [QFJ Message Processor] DEBUG org.apache.camel.processor.SendProcessor  - >>>> Endpoint[jmsUS://topic:dummy] Exchange[.....Removed for brevity ]]
10:11:40,372 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  - Executing callback on JMS Session: com.tibco.tibjms.TibjmsxSessionImp@f1c18
10:11:40,398 [QFJ Message Processor] WARN  org.apache.camel.component.jms.JmsBinding  - Cannot determine specific JmsMessage type to use from body class. Will use generic JmsMessage. Body class: com.csfb.oddlots.model.MarketData. If you want to send a POJO then your class might need to implement java.io.Serializable, or you can force a specific type by setting the jmsMessageType option on the JMS endpoint.
10:11:40,399 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsBinding  - Ignoring non primitive header: EventCategory of class: org.apache.camel.component.quickfixj.QuickfixjEventCategory with value: AppMessageReceived
10:11:40,399 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsBinding  - Ignoring non primitive header: SessionID of class: quickfix.SessionID with value: FIX.4.2:CS_MD_FLOW1->CX
10:11:40,400 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsConfiguration  - Sending JMS message to: Topic[T.NY.COLT.FBID.REDC.2I65BYCO1] with message:  Header={ JMSMessageID={null} JMSDestination={null} JMSReplyTo={null} JMSDeliveryMode={PERSISTENT} JMSRedelivered={false} JMSCorrelationID={null} JMSType={null} JMSTimestamp={0} JMSExpiration={0} JMSPriority={4} } Properties={ breadcrumbId={String:ID-USD09546426-55464-1335535888673-0-4233} MessageType={String:W} }



It won't work with this code.

	//Here I am setting adding the destination name to a Map of Headers
	//Using  jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayload(), msgHeaders);

	public void publish(Publishable publishable){
		Map<String,String> origMsgHeaders = publishable.getPublishProperties();
		Map<String,Object> msgHeaders = new HashMap<String, Object>(origMsgHeaders);
		String destinationName = null;

		if(!StringUtils.isEmpty(destinationPrefix)){
			destinationName = String.format("%s.%s", destinationPrefix, publishable.getPublishTopicName());
		}else{
			destinationName = publishable.getPublishTopicName();
		}

		if(log.isDebugEnabled()){
			log.debug("Destination is " + destinationName);
		}
		msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName);
		jmsProducer.sendBodyAndHeaders(endPointUri, publishable.getPayload(), msgHeaders);
	}


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.GenericCamelPublisher  - Destination is T.NY.COLT.FBID.REDC.2I65BYCO1
9:58:41,106 [QFJ Message Processor] DEBUG org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  - Executing callback on JMS Session: om.tibco.tibjms.TibjmsxSessionImp@db89c2
09:58:41,151 [QFJ Message Processor] WARN  org.apache.camel.processor.UnitOfWorkProcessor  - Caught unhandled exception while processing ExchangeId: ID-USD09546426-55398-1335535108913-0-4246 org.springframework.jms.InvalidDestinationException: Not allowed to create destination; nested exception is javax.jms.InvalidDestinationException: Not allowed to create destination



-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Sent: Friday, April 27, 2012 1:58 AM
To: users@camel.apache.org
Subject: Re: JMS Endpoint Reuse and sending to different destinations @ Runtime

On Thu, Apr 26, 2012 at 11:02 PM, Gershaw, Geoffrey
<ge...@credit-suisse.com> wrote:
> Hi Claus,
>
> Thanks for the reply. I agree there is a permissions issue on the JMS Broker. The problem is that I can't see in the logs the name of the topic where 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
>  msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName);
>  jmsProducer.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.GenericCamelPublisher  - Destination is  T.NY.COLT.FBID.REDC.2I65BYCO1
>
> But it looks like ultimately its trying to send jmsUS://topic
>
> 15:03:46,117 [QFJ Message Processor] DEBUG  org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic] Exchange[Message:8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.051117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100=CX7101=UPD7102=156481757528=010=202]
>
> 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 @ Runtime
>
> 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
> <ge...@credit-suisse.com> 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.       A method that returns the Topic name postfix.
>>
>> 2.       A method that returns a Map<String,String> 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 {
>>
>>      private ProducerTemplate jmsProducer;
>>
>>      private static final Logger log =
>> Logger.getLogger(GenericCamelPublisher.class);
>>
>>      private String destinationPrefix;
>>
>>      private String endPointUri;
>>
>>
>>
>>      public GenericCamelPublisher(ProducerTemplate jmsProducer, String
>> destinationPrefix, String endPointUri){
>>
>>            this.jmsProducer = jmsProducer;
>>
>>            this.destinationPrefix = destinationPrefix;
>>
>>            this.endPointUri = endPointUri;
>>
>>      }
>>
>>
>>
>>      public void publish(Publishable publishable){
>>
>>            Map<String,String> origMsgHeaders =
>> publishable.getPublishProperties();
>>
>>            Map<String,Object> msgHeaders = new HashMap<String,
>> Object>(origMsgHeaders);
>>
>>            String destinationName = null;
>>
>>
>>
>>            if(!StringUtils.isEmpty(destinationPrefix)){
>>
>>                  destinationName = String.format("%s.%s",
>> destinationPrefix, publishable.getPublishTopicName());
>>
>>            }else{
>>
>>                  destinationName = publishable.getPublishTopicName();
>>
>>            }
>>
>>
>>
>>            if(log.isDebugEnabled()){
>>
>>                  log.debug("Destination is " + destinationName);
>>
>>            }
>>
>>            msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME,
>> destinationName);
>>
>>            jmsProducer.sendBodyAndHeaders(endPointUri,
>> publishable.getPayload(), msgHeaders);
>>
>>      }
>>
>> }
>>
>>
>>
>> I receive the following output
>>
>>
>>
>> 15:03:46,115 [QFJ Message Processor] DEBUG
>> com.csfb.oddlots.creditex.md.GenericCamelPublisher  - Destination is
>> T.NY.COLT.FBID.REDC.2I65BYCO1
>>
>> 15:03:46,115 [QFJ Message Processor] DEBUG
>> org.apache.camel.impl.DefaultComponent  - Creating endpoint
>> uri=[jmsUS://topic], path=[topic], parameters=[{}]
>>
>> 15:03:46,116 [QFJ Message Processor] DEBUG
>> org.apache.camel.spring.SpringCamelContext  - 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  - Starting producer:
>> Producer[jmsUS://topic]
>>
>> 15:03:46,117 [QFJ Message Processor] DEBUG
>> org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic]
>> Exchange[Message:
>> 8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.0
>> 51117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100
>> =CX7101=UPD7102=156481757528=010=202]
>>
>> 15:03:46,316 [QFJ Message Processor] DEBUG
>> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  -
>> Executing callback on JMS Session:
>> com.tibco.tibjms.TibjmsxSessionImp@1846149
>>
>> 15:03:46,377 [QFJ Message Processor] WARN
>> org.apache.camel.processor.UnitOfWorkProcessor  - 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
>>
>>                at
>> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt
>> ils.java:285)
>>
>>                at
>> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm
>> sAccessor.java:168)
>>
>>                at
>> 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
>>
>>
>>
>>
>> ===============================================================================
>> Please access the attached hyperlink for an important electronic communications disclaimer:
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>> ===============================================================================
>>
>
>
>
> --
> 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/
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
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/

=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 


Re: JMS Endpoint Reuse and sending to different destinations @ Runtime

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Apr 26, 2012 at 11:02 PM, Gershaw, Geoffrey
<ge...@credit-suisse.com> wrote:
> Hi Claus,
>
> Thanks for the reply. I agree there is a permissions issue on the JMS Broker. The problem is that I can't see in the logs the name of the topic where 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
>  msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName);
>  jmsProducer.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.GenericCamelPublisher  - Destination is  T.NY.COLT.FBID.REDC.2I65BYCO1
>
> But it looks like ultimately its trying to send jmsUS://topic
>
> 15:03:46,117 [QFJ Message Processor] DEBUG  org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic] Exchange[Message:8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.051117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100=CX7101=UPD7102=156481757528=010=202]
>
> 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 @ Runtime
>
> 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
> <ge...@credit-suisse.com> 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.       A method that returns the Topic name postfix.
>>
>> 2.       A method that returns a Map<String,String> 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 {
>>
>>      private ProducerTemplate jmsProducer;
>>
>>      private static final Logger log =
>> Logger.getLogger(GenericCamelPublisher.class);
>>
>>      private String destinationPrefix;
>>
>>      private String endPointUri;
>>
>>
>>
>>      public GenericCamelPublisher(ProducerTemplate jmsProducer, String
>> destinationPrefix, String endPointUri){
>>
>>            this.jmsProducer = jmsProducer;
>>
>>            this.destinationPrefix = destinationPrefix;
>>
>>            this.endPointUri = endPointUri;
>>
>>      }
>>
>>
>>
>>      public void publish(Publishable publishable){
>>
>>            Map<String,String> origMsgHeaders =
>> publishable.getPublishProperties();
>>
>>            Map<String,Object> msgHeaders = new HashMap<String,
>> Object>(origMsgHeaders);
>>
>>            String destinationName = null;
>>
>>
>>
>>            if(!StringUtils.isEmpty(destinationPrefix)){
>>
>>                  destinationName = String.format("%s.%s",
>> destinationPrefix, publishable.getPublishTopicName());
>>
>>            }else{
>>
>>                  destinationName = publishable.getPublishTopicName();
>>
>>            }
>>
>>
>>
>>            if(log.isDebugEnabled()){
>>
>>                  log.debug("Destination is " + destinationName);
>>
>>            }
>>
>>            msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME,
>> destinationName);
>>
>>            jmsProducer.sendBodyAndHeaders(endPointUri,
>> publishable.getPayload(), msgHeaders);
>>
>>      }
>>
>> }
>>
>>
>>
>> I receive the following output
>>
>>
>>
>> 15:03:46,115 [QFJ Message Processor] DEBUG
>> com.csfb.oddlots.creditex.md.GenericCamelPublisher  - Destination is
>> T.NY.COLT.FBID.REDC.2I65BYCO1
>>
>> 15:03:46,115 [QFJ Message Processor] DEBUG
>> org.apache.camel.impl.DefaultComponent  - Creating endpoint
>> uri=[jmsUS://topic], path=[topic], parameters=[{}]
>>
>> 15:03:46,116 [QFJ Message Processor] DEBUG
>> org.apache.camel.spring.SpringCamelContext  - 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  - Starting producer:
>> Producer[jmsUS://topic]
>>
>> 15:03:46,117 [QFJ Message Processor] DEBUG
>> org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic]
>> Exchange[Message:
>> 8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.0
>> 51117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100
>> =CX7101=UPD7102=156481757528=010=202]
>>
>> 15:03:46,316 [QFJ Message Processor] DEBUG
>> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  -
>> Executing callback on JMS Session:
>> com.tibco.tibjms.TibjmsxSessionImp@1846149
>>
>> 15:03:46,377 [QFJ Message Processor] WARN
>> org.apache.camel.processor.UnitOfWorkProcessor  - 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
>>
>>                at
>> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt
>> ils.java:285)
>>
>>                at
>> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm
>> sAccessor.java:168)
>>
>>                at
>> 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
>>
>>
>>
>>
>> ===============================================================================
>> Please access the attached hyperlink for an important electronic communications disclaimer:
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>> ===============================================================================
>>
>
>
>
> --
> 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/
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
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/

RE: JMS Endpoint Reuse and sending to different destinations @ Runtime

Posted by "Gershaw, Geoffrey" <ge...@credit-suisse.com>.
Hi Claus,

Thanks for the reply. I agree there is a permissions issue on the JMS Broker. The problem is that I can't see in the logs the name of the topic where I'm publishing.

I am using the ProducerTemplate 
  msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME, destinationName);
  jmsProducer.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.GenericCamelPublisher  - Destination is  T.NY.COLT.FBID.REDC.2I65BYCO1

But it looks like ultimately its trying to send jmsUS://topic

15:03:46,117 [QFJ Message Processor] DEBUG  org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic] Exchange[Message:8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.051117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100=CX7101=UPD7102=156481757528=010=202]

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 @ Runtime

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
<ge...@credit-suisse.com> 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.       A method that returns the Topic name postfix.
>
> 2.       A method that returns a Map<String,String> 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 {
>
>      private ProducerTemplate jmsProducer;
>
>      private static final Logger log =
> Logger.getLogger(GenericCamelPublisher.class);
>
>      private String destinationPrefix;
>
>      private String endPointUri;
>
>
>
>      public GenericCamelPublisher(ProducerTemplate jmsProducer, String
> destinationPrefix, String endPointUri){
>
>            this.jmsProducer = jmsProducer;
>
>            this.destinationPrefix = destinationPrefix;
>
>            this.endPointUri = endPointUri;
>
>      }
>
>
>
>      public void publish(Publishable publishable){
>
>            Map<String,String> origMsgHeaders =
> publishable.getPublishProperties();
>
>            Map<String,Object> msgHeaders = new HashMap<String,
> Object>(origMsgHeaders);
>
>            String destinationName = null;
>
>
>
>            if(!StringUtils.isEmpty(destinationPrefix)){
>
>                  destinationName = String.format("%s.%s",
> destinationPrefix, publishable.getPublishTopicName());
>
>            }else{
>
>                  destinationName = publishable.getPublishTopicName();
>
>            }
>
>
>
>            if(log.isDebugEnabled()){
>
>                  log.debug("Destination is " + destinationName);
>
>            }
>
>            msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME,
> destinationName);
>
>            jmsProducer.sendBodyAndHeaders(endPointUri,
> publishable.getPayload(), msgHeaders);
>
>      }
>
> }
>
>
>
> I receive the following output
>
>
>
> 15:03:46,115 [QFJ Message Processor] DEBUG
> com.csfb.oddlots.creditex.md.GenericCamelPublisher  - Destination is
> T.NY.COLT.FBID.REDC.2I65BYCO1
>
> 15:03:46,115 [QFJ Message Processor] DEBUG
> org.apache.camel.impl.DefaultComponent  - Creating endpoint
> uri=[jmsUS://topic], path=[topic], parameters=[{}]
>
> 15:03:46,116 [QFJ Message Processor] DEBUG
> org.apache.camel.spring.SpringCamelContext  - 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  - Starting producer:
> Producer[jmsUS://topic]
>
> 15:03:46,117 [QFJ Message Processor] DEBUG
> org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic]
> Exchange[Message:
> 8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.0
> 51117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100
> =CX7101=UPD7102=156481757528=010=202]
>
> 15:03:46,316 [QFJ Message Processor] DEBUG
> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  -
> Executing callback on JMS Session:
> com.tibco.tibjms.TibjmsxSessionImp@1846149
>
> 15:03:46,377 [QFJ Message Processor] WARN
> org.apache.camel.processor.UnitOfWorkProcessor  - 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
>
>                at
> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt
> ils.java:285)
>
>                at
> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm
> sAccessor.java:168)
>
>                at
> 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
>
>
>
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
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/

=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 


Re: JMS Endpoint Reuse and sending to different destinations @ Runtime

Posted by Claus Ibsen <cl...@gmail.com>.
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
<ge...@credit-suisse.com> 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.       A method that returns the Topic name postfix.
>
> 2.       A method that returns a Map<String,String> 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 {
>
>      private ProducerTemplate jmsProducer;
>
>      private static final Logger log =
> Logger.getLogger(GenericCamelPublisher.class);
>
>      private String destinationPrefix;
>
>      private String endPointUri;
>
>
>
>      public GenericCamelPublisher(ProducerTemplate jmsProducer, String
> destinationPrefix, String endPointUri){
>
>            this.jmsProducer = jmsProducer;
>
>            this.destinationPrefix = destinationPrefix;
>
>            this.endPointUri = endPointUri;
>
>      }
>
>
>
>      public void publish(Publishable publishable){
>
>            Map<String,String> origMsgHeaders =
> publishable.getPublishProperties();
>
>            Map<String,Object> msgHeaders = new HashMap<String,
> Object>(origMsgHeaders);
>
>            String destinationName = null;
>
>
>
>            if(!StringUtils.isEmpty(destinationPrefix)){
>
>                  destinationName = String.format("%s.%s",
> destinationPrefix, publishable.getPublishTopicName());
>
>            }else{
>
>                  destinationName = publishable.getPublishTopicName();
>
>            }
>
>
>
>            if(log.isDebugEnabled()){
>
>                  log.debug("Destination is " + destinationName);
>
>            }
>
>            msgHeaders.put(JmsConstants.JMS_DESTINATION_NAME,
> destinationName);
>
>            jmsProducer.sendBodyAndHeaders(endPointUri,
> publishable.getPayload(), msgHeaders);
>
>      }
>
> }
>
>
>
> I receive the following output
>
>
>
> 15:03:46,115 [QFJ Message Processor] DEBUG
> com.csfb.oddlots.creditex.md.GenericCamelPublisher  - Destination is
> T.NY.COLT.FBID.REDC.2I65BYCO1
>
> 15:03:46,115 [QFJ Message Processor] DEBUG
> org.apache.camel.impl.DefaultComponent  - Creating endpoint
> uri=[jmsUS://topic], path=[topic], parameters=[{}]
>
> 15:03:46,116 [QFJ Message Processor] DEBUG
> org.apache.camel.spring.SpringCamelContext  - 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  - Starting producer:
> Producer[jmsUS://topic]
>
> 15:03:46,117 [QFJ Message Processor] DEBUG
> org.apache.camel.impl.ProducerCache  - 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  - >>>> Endpoint[jmsUS://topic]
> Exchange[Message:
> 8=FIXT.1.19=17835=S15=USD22=R48=2I65BYCO155=60200560=20120425-19:03:46.0
> 51117=15648175132=95134=50000167=INDEX_CDS423=6537=1632=0647=06372=Y7100
> =CX7101=UPD7102=156481757528=010=202]
>
> 15:03:46,316 [QFJ Message Processor] DEBUG
> org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate  -
> Executing callback on JMS Session:
> com.tibco.tibjms.TibjmsxSessionImp@1846149
>
> 15:03:46,377 [QFJ Message Processor] WARN
> org.apache.camel.processor.UnitOfWorkProcessor  - 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
>
>                at
> org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUt
> ils.java:285)
>
>                at
> org.springframework.jms.support.JmsAccessor.convertJmsAccessException(Jm
> sAccessor.java:168)
>
>                at
> 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
>
>
>
>
> ===============================================================================
> Please access the attached hyperlink for an important electronic communications disclaimer:
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ===============================================================================
>



-- 
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/