You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by icucode <fr...@gmail.com> on 2009/01/19 12:54:15 UTC

Missing attachments

Hi,

I'm trying to send attachments attached to the message that is sent to the
queue but they seem to vanish on the way for some reason; because on the
consumer side they no longer exist.

== producer ==
public static void sendMessageInOnly(File attachment)
{
   Endpoint endpoint = camel.getEndpoint(address);
   Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);

   exchange.getIn().addAttachment(attachment.getName(), new DataHandler(new
FileDataSource(attachment)));
   
   Producer producer = endpoint.createProducer();
   producer.start();
   producer.process(exchange);
   producer.stop();
}
Note: attachment is valid and everything seems ok on the producer side.

== Consumer ==
public void process(Exchange exchange) throws Exception
{
   System.out.println("Recieved message...");
   System.out.println("Message has attachments: " +
exchange.getIn().hasAttachments());
}
Note: hasAttachments() returns false.

public class ConsumerRoute extends RouteBuilder
{
    @Override
    public void configure() throws Exception
    {
        from("jms:queue:jobs").process(new JobConsumer());
    }
}

In the debug output from the consumer, attachments aren't even listed -
only; Pattern, Headers, BodyType and Body. In the headers section there are
only JMS specific properties. How can I fetch the attachments if
getAttachments() isn't the right way?


Thanks
-- 
View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21541575.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Missing attachments

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jan 19, 2009 at 12:54 PM, icucode <fr...@gmail.com> wrote:
>
> Hi,
>
> I'm trying to send attachments attached to the message that is sent to the
> queue but they seem to vanish on the way for some reason; because on the
> consumer side they no longer exist.
>
> == producer ==
> public static void sendMessageInOnly(File attachment)
> {
>   Endpoint endpoint = camel.getEndpoint(address);
>   Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);
>
>   exchange.getIn().addAttachment(attachment.getName(), new DataHandler(new
> FileDataSource(attachment)));
>
>   Producer producer = endpoint.createProducer();
>   producer.start();
>   producer.process(exchange);
>   producer.stop();
> }
> Note: attachment is valid and everything seems ok on the producer side.
>
> == Consumer ==
> public void process(Exchange exchange) throws Exception
> {
>   System.out.println("Recieved message...");
>   System.out.println("Message has attachments: " +
> exchange.getIn().hasAttachments());
> }
> Note: hasAttachments() returns false.
Yeah thats a bug we have fixed in the next Camel 1.6 I think.

>
> public class ConsumerRoute extends RouteBuilder
> {
>    @Override
>    public void configure() throws Exception
>    {
>        from("jms:queue:jobs").process(new JobConsumer());
>    }
> }
>
> In the debug output from the consumer, attachments aren't even listed -
> only; Pattern, Headers, BodyType and Body. In the headers section there are
> only JMS specific properties. How can I fetch the attachments if
> getAttachments() isn't the right way?
Attachements to my knowledge hasn't been used much and I could suspect
some transports types / components dont support them.
It was added to Camel as its used in JBI. But pure Camel routing
doesnt really use it.
Its definitely not (yet) supported over JMS with Camel.

You should store it in the body instead.

>
>
> Thanks
> --
> View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21541575.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Missing attachments

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Step back a bit.

You are doing an InOnly (aka fire and forget) exchange where you want
to send a message to a JMS queue.

The attachemtns is not supported so you should store it in the BODY instead.

An Exchange will always have an exchange pattern set. So creating an
Exchange without setting it will default to InOnly (AFAIR).


Could you recap what your problem is, when you send the attachement
directly in the BODY?



On Wed, Jan 21, 2009 at 9:30 AM, icucode <fr...@gmail.com> wrote:
>
> Hi Charles,
>
> Unfortunately the change didn't make any difference. It seems that InOnly is
> the default since it doesn't change in the tracelog when removing it from
> the sendMessageInOnly method. I have to have missed something else, do I
> have to set header properties to tell the queue which kind of encoding,
> filetype that the queue should interpreter it as, or add more information to
> the DataHandler object?
>
> [TraceInterceptor on consumer]
> ...Pattern:InOnly , Headers:{JMSXGroupID=null, JMSCorrelationID=null,
> JMSType=null, JMSExpiration=0,
> JMSMessageID=ID:Andreas-6527-1232525848004-0:9:1:1:1,
> JMSRedelivered=false, JMSDeliveryMode=2, JMSPriority=4, JMSReplyTo=null,
> JMSTimestamp=1232525848332, JMSDestination=queue://jobs} , BodyType:null
> , Body:null
>
>
> Kind Regards
> Andreas
>
>
> cmoulliard wrote:
>>
>> Hi,
>>
>> Have you try to create your exchange without mentioning the
>> ExchangePattern like this ?
>>
>> Exchange exchange = endpoint.createExchange();
>>
>>
>>
>> icucode wrote:
>>>
>>> Hi,
>>>
>>> I'm trying to send attachments attached to the message that is sent to
>>> the queue but they seem to vanish on the way for some reason; because on
>>> the consumer side they no longer exist.
>>>
>>> == producer ==
>>> public static void sendMessageInOnly(File attachment)
>>> {
>>>    Endpoint endpoint = camel.getEndpoint(address);
>>>    Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);
>>>
>>>    exchange.getIn().addAttachment(attachment.getName(), new
>>> DataHandler(new FileDataSource(attachment)));
>>>
>>>    Producer producer = endpoint.createProducer();
>>>    producer.start();
>>>    producer.process(exchange);
>>>    producer.stop();
>>> }
>>> Note: attachment is valid and everything seems ok on the producer side.
>>>
>>> == Consumer ==
>>> public void process(Exchange exchange) throws Exception
>>> {
>>>    System.out.println("Recieved message...");
>>>    System.out.println("Message has attachments: " +
>>> exchange.getIn().hasAttachments());
>>> }
>>> Note: hasAttachments() returns false.
>>>
>>> public class ConsumerRoute extends RouteBuilder
>>> {
>>>     @Override
>>>     public void configure() throws Exception
>>>     {
>>>         from("jms:queue:jobs").process(new JobConsumer());
>>>     }
>>> }
>>>
>>> In the debug output from the consumer, attachments aren't even listed -
>>> only; Pattern, Headers, BodyType and Body. In the headers section there
>>> are only JMS specific properties. How can I fetch the attachments if
>>> getAttachments() isn't the right way?
>>>
>>>
>>> Thanks
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21578842.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Missing attachments

Posted by icucode <fr...@gmail.com>.
It was my lack of knowledge that brought this thread up. I've read the JMS
component code and it doesn't support attachments which I first thought. The
attachment methods is only valid if you are using the mail component as
you've stated Charles. If you want to send attachments with JMS you have to
do so in the body. 

Thanks


Kind Regards
Andreas



cmoulliard wrote:
> 
> I see in your trace that your body object is null. So, nothing will be
> consumed by the endpoint. Have you tried the following code (which is a
> test case of camel-component) ?
> 
> -
> camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentTest.java
> 
> and consult the camel wiki page : http://camel.apache.org/mail.html
> 
> Charles
> 
> 
> icucode wrote:
>> 
>> Hi Charles,
>> 
>> Unfortunately the change didn't make any difference. It seems that InOnly
>> is the default since it doesn't change in the tracelog when removing it
>> from the sendMessageInOnly method. I have to have missed something else,
>> do I have to set header properties to tell the queue which kind of
>> encoding, filetype that the queue should interpreter it as, or add more
>> information to the DataHandler object?
>> 
>> [TraceInterceptor on consumer]
>> ...Pattern:InOnly , Headers:{JMSXGroupID=null, JMSCorrelationID=null,
>> JMSType=null, JMSExpiration=0,
>> JMSMessageID=ID:Andreas-6527-1232525848004-0:9:1:1:1,
>> JMSRedelivered=false, JMSDeliveryMode=2, JMSPriority=4, JMSReplyTo=null,
>> JMSTimestamp=1232525848332, JMSDestination=queue://jobs} , BodyType:null
>> , Body:null
>> 
>> 
>> Kind Regards
>> Andreas 
>> 
>> 
>> cmoulliard wrote:
>>> 
>>> Hi,
>>> 
>>> Have you try to create your exchange without mentioning the
>>> ExchangePattern like this ?
>>> 
>>> Exchange exchange = endpoint.createExchange();
>>> 
>>> 
>>> 
>>> icucode wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I'm trying to send attachments attached to the message that is sent to
>>>> the queue but they seem to vanish on the way for some reason; because
>>>> on the consumer side they no longer exist.
>>>> 
>>>> == producer ==
>>>> public static void sendMessageInOnly(File attachment)
>>>> {
>>>>    Endpoint endpoint = camel.getEndpoint(address);
>>>>    Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);
>>>> 
>>>>    exchange.getIn().addAttachment(attachment.getName(), new
>>>> DataHandler(new FileDataSource(attachment)));
>>>>    
>>>>    Producer producer = endpoint.createProducer();
>>>>    producer.start();
>>>>    producer.process(exchange);
>>>>    producer.stop();
>>>> }
>>>> Note: attachment is valid and everything seems ok on the producer side.
>>>> 
>>>> == Consumer ==
>>>> public void process(Exchange exchange) throws Exception
>>>> {
>>>>    System.out.println("Recieved message...");
>>>>    System.out.println("Message has attachments: " +
>>>> exchange.getIn().hasAttachments());
>>>> }
>>>> Note: hasAttachments() returns false.
>>>> 
>>>> public class ConsumerRoute extends RouteBuilder
>>>> {
>>>>     @Override
>>>>     public void configure() throws Exception
>>>>     {
>>>>         from("jms:queue:jobs").process(new JobConsumer());
>>>>     }
>>>> }
>>>> 
>>>> In the debug output from the consumer, attachments aren't even listed -
>>>> only; Pattern, Headers, BodyType and Body. In the headers section there
>>>> are only JMS specific properties. How can I fetch the attachments if
>>>> getAttachments() isn't the right way?
>>>> 
>>>> 
>>>> Thanks
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21584605.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Missing attachments

Posted by cmoulliard <cm...@gmail.com>.
I see in your trace that your body object is null. So, nothing will be
consumed by the endpoint. Have you tried the following code (which is a test
case of camel-component) ?

-
camel/trunk/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailAttachmentTest.java

and consult the camel wiki page : http://camel.apache.org/mail.html

Charles


icucode wrote:
> 
> Hi Charles,
> 
> Unfortunately the change didn't make any difference. It seems that InOnly
> is the default since it doesn't change in the tracelog when removing it
> from the sendMessageInOnly method. I have to have missed something else,
> do I have to set header properties to tell the queue which kind of
> encoding, filetype that the queue should interpreter it as, or add more
> information to the DataHandler object?
> 
> [TraceInterceptor on consumer]
> ...Pattern:InOnly , Headers:{JMSXGroupID=null, JMSCorrelationID=null,
> JMSType=null, JMSExpiration=0,
> JMSMessageID=ID:Andreas-6527-1232525848004-0:9:1:1:1,
> JMSRedelivered=false, JMSDeliveryMode=2, JMSPriority=4, JMSReplyTo=null,
> JMSTimestamp=1232525848332, JMSDestination=queue://jobs} , BodyType:null
> , Body:null
> 
> 
> Kind Regards
> Andreas 
> 
> 
> cmoulliard wrote:
>> 
>> Hi,
>> 
>> Have you try to create your exchange without mentioning the
>> ExchangePattern like this ?
>> 
>> Exchange exchange = endpoint.createExchange();
>> 
>> 
>> 
>> icucode wrote:
>>> 
>>> Hi,
>>> 
>>> I'm trying to send attachments attached to the message that is sent to
>>> the queue but they seem to vanish on the way for some reason; because on
>>> the consumer side they no longer exist.
>>> 
>>> == producer ==
>>> public static void sendMessageInOnly(File attachment)
>>> {
>>>    Endpoint endpoint = camel.getEndpoint(address);
>>>    Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);
>>> 
>>>    exchange.getIn().addAttachment(attachment.getName(), new
>>> DataHandler(new FileDataSource(attachment)));
>>>    
>>>    Producer producer = endpoint.createProducer();
>>>    producer.start();
>>>    producer.process(exchange);
>>>    producer.stop();
>>> }
>>> Note: attachment is valid and everything seems ok on the producer side.
>>> 
>>> == Consumer ==
>>> public void process(Exchange exchange) throws Exception
>>> {
>>>    System.out.println("Recieved message...");
>>>    System.out.println("Message has attachments: " +
>>> exchange.getIn().hasAttachments());
>>> }
>>> Note: hasAttachments() returns false.
>>> 
>>> public class ConsumerRoute extends RouteBuilder
>>> {
>>>     @Override
>>>     public void configure() throws Exception
>>>     {
>>>         from("jms:queue:jobs").process(new JobConsumer());
>>>     }
>>> }
>>> 
>>> In the debug output from the consumer, attachments aren't even listed -
>>> only; Pattern, Headers, BodyType and Body. In the headers section there
>>> are only JMS specific properties. How can I fetch the attachments if
>>> getAttachments() isn't the right way?
>>> 
>>> 
>>> Thanks
>>> 
>> 
>> 
> 
> 


-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21579357.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Missing attachments

Posted by icucode <fr...@gmail.com>.
Hi Charles,

Unfortunately the change didn't make any difference. It seems that InOnly is
the default since it doesn't change in the tracelog when removing it from
the sendMessageInOnly method. I have to have missed something else, do I
have to set header properties to tell the queue which kind of encoding,
filetype that the queue should interpreter it as, or add more information to
the DataHandler object?

[TraceInterceptor on consumer]
...Pattern:InOnly , Headers:{JMSXGroupID=null, JMSCorrelationID=null,
JMSType=null, JMSExpiration=0,
JMSMessageID=ID:Andreas-6527-1232525848004-0:9:1:1:1,
JMSRedelivered=false, JMSDeliveryMode=2, JMSPriority=4, JMSReplyTo=null,
JMSTimestamp=1232525848332, JMSDestination=queue://jobs} , BodyType:null
, Body:null


Kind Regards
Andreas 


cmoulliard wrote:
> 
> Hi,
> 
> Have you try to create your exchange without mentioning the
> ExchangePattern like this ?
> 
> Exchange exchange = endpoint.createExchange();
> 
> 
> 
> icucode wrote:
>> 
>> Hi,
>> 
>> I'm trying to send attachments attached to the message that is sent to
>> the queue but they seem to vanish on the way for some reason; because on
>> the consumer side they no longer exist.
>> 
>> == producer ==
>> public static void sendMessageInOnly(File attachment)
>> {
>>    Endpoint endpoint = camel.getEndpoint(address);
>>    Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);
>> 
>>    exchange.getIn().addAttachment(attachment.getName(), new
>> DataHandler(new FileDataSource(attachment)));
>>    
>>    Producer producer = endpoint.createProducer();
>>    producer.start();
>>    producer.process(exchange);
>>    producer.stop();
>> }
>> Note: attachment is valid and everything seems ok on the producer side.
>> 
>> == Consumer ==
>> public void process(Exchange exchange) throws Exception
>> {
>>    System.out.println("Recieved message...");
>>    System.out.println("Message has attachments: " +
>> exchange.getIn().hasAttachments());
>> }
>> Note: hasAttachments() returns false.
>> 
>> public class ConsumerRoute extends RouteBuilder
>> {
>>     @Override
>>     public void configure() throws Exception
>>     {
>>         from("jms:queue:jobs").process(new JobConsumer());
>>     }
>> }
>> 
>> In the debug output from the consumer, attachments aren't even listed -
>> only; Pattern, Headers, BodyType and Body. In the headers section there
>> are only JMS specific properties. How can I fetch the attachments if
>> getAttachments() isn't the right way?
>> 
>> 
>> Thanks
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21578842.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Missing attachments

Posted by cmoulliard <cm...@gmail.com>.
Hi,

Have you try to create your exchange without mentioning the ExchangePattern
like this ?

Exchange exchange = endpoint.createExchange();



icucode wrote:
> 
> Hi,
> 
> I'm trying to send attachments attached to the message that is sent to the
> queue but they seem to vanish on the way for some reason; because on the
> consumer side they no longer exist.
> 
> == producer ==
> public static void sendMessageInOnly(File attachment)
> {
>    Endpoint endpoint = camel.getEndpoint(address);
>    Exchange exchange = endpoint.createExchange(ExchangePattern.InOnly);
> 
>    exchange.getIn().addAttachment(attachment.getName(), new
> DataHandler(new FileDataSource(attachment)));
>    
>    Producer producer = endpoint.createProducer();
>    producer.start();
>    producer.process(exchange);
>    producer.stop();
> }
> Note: attachment is valid and everything seems ok on the producer side.
> 
> == Consumer ==
> public void process(Exchange exchange) throws Exception
> {
>    System.out.println("Recieved message...");
>    System.out.println("Message has attachments: " +
> exchange.getIn().hasAttachments());
> }
> Note: hasAttachments() returns false.
> 
> public class ConsumerRoute extends RouteBuilder
> {
>     @Override
>     public void configure() throws Exception
>     {
>         from("jms:queue:jobs").process(new JobConsumer());
>     }
> }
> 
> In the debug output from the consumer, attachments aren't even listed -
> only; Pattern, Headers, BodyType and Body. In the headers section there
> are only JMS specific properties. How can I fetch the attachments if
> getAttachments() isn't the right way?
> 
> 
> Thanks
> 


-----
Charles Moulliard
SOA Architect

My Blog :  http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/  
-- 
View this message in context: http://www.nabble.com/Missing-attachments-tp21541575s22882p21545359.html
Sent from the Camel - Users mailing list archive at Nabble.com.