Agreed - we should now be able to easily configure any JMS endpoint
with any required settings.

Having said that - if someone fancies submitting a patch we could add
an MQ based Component & Endpoint to expose all the MQ specific
properties more easily - lettting folks stick to Uris if they prefer.

On 08/12/2008, Claus Ibsen <[EMAIL PROTECTED]> wrote:
> Hi
>
> If you look at the latest commits today from James Strachan I think he
> add to Camel 2.0 a solution to your problem.
> See his comment on CAMEL-505
> http://issues.apache.org/activemq/browse/CAMEL-505
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>
>
>
> On Sun, Dec 7, 2008 at 11:20 AM, Tomasz Domzal
> <[EMAIL PROTECTED]> wrote:
>>
>> I had exactly same problem few months ago and came up with quick and dirty
>> solution.
>> By default all attributes on Camel JMS URI (ex. targetClient for Websphare
>> MQ) are are passed to camel JmsComponent object. Such behavior is not what
>> we want in case of additional destination attributes (like MS MQ
>> 'targetClient'). But in JmsComponent object there is method:
>>
>>  protected String convertPathToActualDestination(String path, Map
>> parameters)
>>
>> which overloaded can modify this behavior. There is extended JmsComponent
>> code. Please find more description in supplied javadoc snippet:
>>
>> // -------------------
>>
>> /**
>>  * JMSComponent with modification that allows setting attributes on JMS
>> destination object.<br/>
>>  * Attributes enumerated in 'destinationArgs' attribute will be set as
>> attributes on destination URI instead on underlying [EMAIL PROTECTED] 
>> JmsComponent}
>> object.
>>  * For example setting 'targetClient' attribute on Webshere MQ in Camel
>> JMS
>> endpoint URI should look like:
>>  *
>> <pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
>>  * where jmsMqComp is bean id of [EMAIL PROTECTED]
>> JmsComponentWithDestinationAttributes} instance.<br/>
>>  * (Please note URI attribute setting method on Websphere MQ works only
>> with
>> URI queue format - thats the reason
>>  * there is keyword 'queue' is used twice in this example - first is from
>> Camel URI format, second starts WS MQ queue URI)
>>  */
>> public class JmsComponentWithDestinationAttributes extends JmsComponent {
>>
>>  private Log log =
>> LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
>>
>>  @Override
>>  protected String convertPathToActualDestination(String path, Map
>> parameters) {
>>    if (log.isDebugEnabled())
>>      log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
>>    String subject = super.convertPathToActualDestination(path,
>> parameters);
>>    // attributes enumerated in 'destinationArgs' are removed from map and
>> appended as destination options
>>    if (parameters.containsKey("destinationArgs")) {
>>      StringBuffer subjectBuf = new StringBuffer(subject);
>>      boolean subjectHasOptions = (subject.indexOf('?')!=-1);
>>      String destinationArgs = (String)
>> parameters.remove("destinationArgs");
>>      String[] args = destinationArgs.split(",");
>>      for (String arg : args) {
>>        if (subjectHasOptions) {
>>          subjectBuf.append("&");
>>        } else {
>>          subjectBuf.append("?");
>>          subjectHasOptions = true;
>>        }
>>        subjectBuf.append(arg);
>>        subjectBuf.append('=');
>>        subjectBuf.append((String) parameters.remove(arg));
>>      }
>>      subject = subjectBuf.toString();
>>    }
>>    if (log.isDebugEnabled())
>>      log.debug("resolved [path: "+subject+"][parameters:
>> "+parameters+"]");
>>    return subject;
>>  }
>> }
>>
>> // -------------------
>>
>> and assuming Spring bean configuration:
>>
>>  <bean id="jmsMqComp"
>> class="com.somecompany.JmsComponentWithDestinationAttributes">
>>    <property name="connectionFactory">
>>      <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
>>        <property name="transportType">
>>          <util:constant
>> static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
>>        </property>
>>        <property name="hostName" value="mq_host"/>
>>        <property name="port" value="mq_port" />
>>        <property name="queueManager" value="mq_qmanager"/>
>>        <property name="channel" value="mq_channel"/>
>>      </bean>
>>    </property>
>>  </bean>
>>
>> JMS URI in Camel:
>>
>>
>> jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
>>
>> will set targetClient=1 option on WS MQ destination.
>>
>> It's definitely not best solution. ActiveMQ has dedicated component in
>> Camel
>> which accepts many AMQ dedicated options. Maybe this is way to go for
>> Websphere MQ also ?
>> --
>> View this message in context:
>> http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Reply via email to