I am talking about the (spring) jms message converter used by the jms
component to create jms messages is handed the correct session.
See the messageConverter option on the JMS component page.

Best regards
Pontus
Send from my phone
Den 4 aug 2012 00:35 skrev "Christian Müller" <[email protected]>:

> I don't think a Converter is the right choice, if you need a JMS connection
> for this. How should the Connector know which broker url should be used?
> You cannot inject dependencies into your converter...
>
> Best,
> Christian
>
> On Fri, Aug 3, 2012 at 8:21 AM, Pontus Ullgren <[email protected]> wrote:
>
> > Hello,
> >
> > Sorry for repeating myself but you should really have a look at doing
> this
> > in a message converter. First you will not have to cast it to a exchange.
> > And second you will then be handed the same session that is used to
> create
> > the producer in the component. So you will participate in the same unit
> of
> > work. Which I doubt is true if you create your own connection/session.
> But
> > I am currently travelling so I can not test this.
> >
> > //Pontus
> > Send from my phone
> > Den 3 aug 2012 00:14 skrev "brenthale" <[email protected]>:
> >
> > > Thanks for all the suggestions.
> > >
> > > I've been trying to create a DataFormat to handle this.  I'm stuck
> trying
> > > to
> > > integrate an ActiveMQ ActiveMQBlobMessage with the
> > > org.apache.camel.Exchange
> > > class working with org.apache.camel.Message's.  You can't typecast one
> > into
> > > the other.
> > >
> > > Here's my current unmarshal method:
> > >
> > >   public Object unmarshal(Exchange exchange, InputStream stream) throws
> > > Exception {
> > >     ActiveMQConnection connection;
> > >     ActiveMQSession session;
> > >
> > >     ActiveMQBlobMessage blobMessage;
> > >
> > >     connection = (ActiveMQConnection)
> > > activeMQConnectionFactory.createConnection();
> > >     connection.start();
> > >
> > >     session = (ActiveMQSession) connection.createSession(false,
> > > Session.AUTO_ACKNOWLEDGE);
> > >
> > >     blobMessage = (ActiveMQBlobMessage)
> > session.createBlobMessage(stream);
> > >     blobMessage.setMessageId(new
> > > MessageId(exchange.getIn().getMessageId()));
> > >
> > >     // Get the data uploaded to the ActiveMQ fileserver
> > >     blobMessage.getBlobUploader().upload(blobMessage);
> > >
> > >     // org.apache.camel.Exchange is a Camel object expecting a
> > > org.apache.camel.Message in the Out.
> > >     // BlobMessage is an ActiveMQ
> > > org.apache.activemq.command.ActiveMQBlobMessage.
> > >     // This line doesn't work. They don't cast.
> > > //    exchange.setOut(blobMessage);
> > >
> > >     // And this was a sad attempt at trying to get around it.
> > > //    DefaultMessage camelMessage = new DefaultMessage();
> > > //    camelMessage.setExchange(exchange);
> > > //    camelMessage.setBody(blobMessage,
> > > org.apache.activemq.command.Message.class);
> > > //    camelMessage.setMessageId(blobMessage.getMessageId().toString());
> > > //    exchange.setOut(camelMessage);    // kinda by-passes things.
> > >
> > > //    if (! (((JmsMessage) message).getJmsMessage() instanceof
> > > BlobMessage))
> > > {
> > >     exchange.setOut((JmsMessage)(BlobMessage)blobMessage);
> > > //      ((JmsMessage)exchange.getOut()).setJmsMessage(blobMessage);
> > >
> > >     return blobMessage;
> > >   }
> > >
> > >
> > > When the setOut() is made I get the following exception.
> > >
> > > exchange.setOut((JmsMessage)(BlobMessage)blobMessage) = Type mismatch
> > Can't
> > > assign org.apache.activemq.command.ActiveMQBlobMessage to
> > > org.apache.camel.Message
> > >
> > >
> > > When working with BlobMessages sent normally (via a producer.send()) I
> am
> > > able to retrieve the BlobMessage this way:
> > >
> > >     if (! (((JmsMessage) message).getJmsMessage() instanceof
> > BlobMessage))
> > > {
> > >       throw new CdsMsgException("Error processing batch message:
> > Expected a
> > > BlobMessage");
> > >     }
> > >     BlobMessage blobMessage = (BlobMessage) ((JmsMessage)
> > > message).getJmsMessage();
> > >
> > > But I'm at a loss as to how to change the Message to a BlobMessage
> inside
> > > of
> > > a DataFormat.
> > >
> > > I assume I'm missing something fairly trivial.
> > >
> > > Thanks,
> > >
> > >
> > >
> > >
> > > -----
> > >
> > > Brent
> > > --
> > > View this message in context:
> > >
> >
> http://camel.465427.n5.nabble.com/Is-it-possible-to-create-a-custom-DataFormat-to-translate-a-message-into-a-BlobMessage-tp5716679p5716720.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com.
> > >
> >
>

Reply via email to