You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org> on 2010/10/05 06:52:40 UTC

[jira] Created: (CAMEL-3195) Allow camel to send custom xmpp packet (Presence packet or PubSub packet) to a xmpp destination

Allow camel to send custom xmpp packet (Presence packet or PubSub packet) to a xmpp destination
-----------------------------------------------------------------------------------------------

                 Key: CAMEL-3195
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
             Project: Apache Camel
          Issue Type: New Feature
          Components: camel-xmpp
            Reporter: Chandra Prakash Joshi


Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])

I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.

I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):

{code:java} 
     from("stream:in?promptMessage=Enter something:").process( new Processor(){
        public void process(Exchange exchange) throws Exception {
                System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
                Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
                exchange.getIn().setBody(p);
            }
            }).to("xmpp:user1@banl080161?password=pass1");
{code}

Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.

Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen updated CAMEL-3195:
-------------------------------

    Fix Version/s: 2.6.0

> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>             Fix For: 2.6.0
>
>         Attachments: Camel-xmpp-pubsub-presence-v2.patch
>
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62774#action_62774 ] 

Chandra Prakash Joshi edited comment on CAMEL-3195 at 10/22/10 1:27 PM:
------------------------------------------------------------------------

Donald,

Thanks for the suggestion. I have attached a patch that serves these requirments:
- The component gets triggerd by Presence/PubSub on input
- Set a doc header in IN message When doc bool is set to true on endpoint (and it gets set when either pubsub or presence is true)

with these changes the below route receives Chat, Presence and PubSub Packets:

{code:java} 
from("xmpp:user2@banl080161/user1@banl080161?password=pass2&pubsub=true&presence=true").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        Packet pk = (Packet)exchange.getIn().getHeader("doc");
        exchange.getIn().setBody(pk.toXML());
    }
}).to("stream:out");
{code} 

A pubsub and presence can be send like below. camel-xmpp does't take responsibility of creating these packets (we will need too many enpoint parameters for that). Please do let me know if you have a better way to do this.

{code:java} 
//Publish to a topic
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        String xmlpayLoad = "<entry xmlns='jabber:x:data'><data>" + exchange.getIn().getBody().toString() + "</data></entry>";
        String NAMESPACE = "http://jabber.org/protocol/pubsub";
        PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("itemid1", new SimplePayload("data", NAMESPACE, xmlpayLoad));
        PubSub p = new PubSub();
        p.setTo("pubsub.banl080161");
        p.setType(IQ.Type.SET);
        p.addExtension(new PublishItem<PayloadItem<?>>("topic1", item));
                        
        String str = p.toXML();
        System.out.println("Publishing to node 'topic1' withp this data: " + str);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&pubsub=true");
{code} 


{code:java} 
//send presence
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
        Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&presence=true");
{code} 


      was (Author: chandraprakashjoshi):
    Donald,

Thanks for the suggestion. I have attached a patch that serves these requirments:
- The component gets triggerd by Presence/PubSub on input
- Set a doc header in IN message When doc bool is set to true on endpoint (and it gets set when either pubsub or presence is true)

with these changes the below path receives Chat, Presence and PubSub Packets:

{code:java} 
from("xmpp:user2@banl080161/user1@banl080161?password=pass2&pubsub=true&presence=true").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        Packet pk = (Packet)exchange.getIn().getHeader("doc");
        exchange.getIn().setBody(pk.toXML());
    }
}).to("stream:out");
{code} 

A pubsub and presence can be send like below. camel-xmpp does't take responsibility of creating these packets (we will need too many enpoint parameters for that). Please do let me know if you have a better way to do this.

{code:java} 
//Publish to a topic
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        String xmlpayLoad = "<entry xmlns='jabber:x:data'><data>" + exchange.getIn().getBody().toString() + "</data></entry>";
        String NAMESPACE = "http://jabber.org/protocol/pubsub";
        PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("itemid1", new SimplePayload("data", NAMESPACE, xmlpayLoad));
        PubSub p = new PubSub();
        p.setTo("pubsub.banl080161");
        p.setType(IQ.Type.SET);
        p.addExtension(new PublishItem<PayloadItem<?>>("topic1", item));
                        
        String str = p.toXML();
        System.out.println("Publishing to node 'topic1' withp this data: " + str);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&pubsub=true");
{code} 


{code:java} 
//send presence
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
        Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&presence=true");
{code} 

  
> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>         Attachments: Camel-xmpp-pubsub-presence.patch
>
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chandra Prakash Joshi updated CAMEL-3195:
-----------------------------------------

    Summary: Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint  (was: Allow camel to send custom xmpp packet (Presence packet or PubSub packet) to a xmpp destination)

> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chandra Prakash Joshi updated CAMEL-3195:
-----------------------------------------

    Attachment:     (was: Camel-xmpp-pubsub-presence.patch)

> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62775#action_62775 ] 

Chandra Prakash Joshi edited comment on CAMEL-3195 at 10/22/10 1:26 PM:
------------------------------------------------------------------------

Enhanced camel-xmpp to send/receive pubsub/presence packets.


      was (Author: chandraprakashjoshi):
    Enhanced xmpp-camel to send/receive pubsub/presence packets.

  
> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>         Attachments: Camel-xmpp-pubsub-presence.patch
>
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62774#action_62774 ] 

Chandra Prakash Joshi commented on CAMEL-3195:
----------------------------------------------

Donald,

Thanks for the suggestion. I have attached a patch that serves these requirments:
- The component gets triggerd by Presence/PubSub on input
- Set a doc header in IN message When doc bool is set to true on endpoint (and it gets set when either pubsub or presence is true)

with these changes the below path receives Chat, Presence and PubSub Packets:

{code:java} 
from("xmpp:user2@banl080161/user1@banl080161?password=pass2&pubsub=true&presence=true").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        Packet pk = (Packet)exchange.getIn().getHeader("doc");
        exchange.getIn().setBody(pk.toXML());
    }
}).to("stream:out");
{code} 

A pubsub and presence can be send like below. camel-xmpp does't take responsibility of creating these packets (we will need too many enpoint parameters for that). Please do let me know if you have a better way to do this.

{code:java} 
//Publish to a topic
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        String xmlpayLoad = "<entry xmlns='jabber:x:data'><data>" + exchange.getIn().getBody().toString() + "</data></entry>";
        String NAMESPACE = "http://jabber.org/protocol/pubsub";
        PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("itemid1", new SimplePayload("data", NAMESPACE, xmlpayLoad));
        PubSub p = new PubSub();
        p.setTo("pubsub.banl080161");
        p.setType(IQ.Type.SET);
        p.addExtension(new PublishItem<PayloadItem<?>>("topic1", item));
                        
        String str = p.toXML();
        System.out.println("Publishing to node 'topic1' withp this data: " + str);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&pubsub=true");
{code} 


{code:java} 
//send presence
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
        Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&presence=true");
{code} 


> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62774#action_62774 ] 

Chandra Prakash Joshi edited comment on CAMEL-3195 at 10/22/10 1:28 PM:
------------------------------------------------------------------------

Donald,

Thanks for the suggestion. I have attached a patch that serves these requirments:
- The component gets triggerd by Presence/PubSub on input
- Set a doc header in IN message When doc bool is set to true on endpoint (and it gets set when either pubsub or presence is true)

with these changes the below route receives Chat, Presence and PubSub Packets:

{code:java} 
from("xmpp:user2@banl080161/user1@banl080161?password=pass2&pubsub=true&presence=true").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        Packet pk = (Packet)exchange.getIn().getHeader("doc");
        exchange.getIn().setBody(pk.toXML());
    }
}).to("stream:out");
{code} 

A pubsub and presence packet can be send like below. camel-xmpp does't take responsibility of creating these packets (we will need too many enpoint parameters for that). Please do let me know if you have a better way to do this.

{code:java} 
//Publish to a topic
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        String xmlpayLoad = "<entry xmlns='jabber:x:data'><data>" + exchange.getIn().getBody().toString() + "</data></entry>";
        String NAMESPACE = "http://jabber.org/protocol/pubsub";
        PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("itemid1", new SimplePayload("data", NAMESPACE, xmlpayLoad));
        PubSub p = new PubSub();
        p.setTo("pubsub.banl080161");
        p.setType(IQ.Type.SET);
        p.addExtension(new PublishItem<PayloadItem<?>>("topic1", item));
                        
        String str = p.toXML();
        System.out.println("Publishing to node 'topic1' withp this data: " + str);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&pubsub=true");
{code} 


{code:java} 
//send presence
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
        Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&presence=true");
{code} 


      was (Author: chandraprakashjoshi):
    Donald,

Thanks for the suggestion. I have attached a patch that serves these requirments:
- The component gets triggerd by Presence/PubSub on input
- Set a doc header in IN message When doc bool is set to true on endpoint (and it gets set when either pubsub or presence is true)

with these changes the below route receives Chat, Presence and PubSub Packets:

{code:java} 
from("xmpp:user2@banl080161/user1@banl080161?password=pass2&pubsub=true&presence=true").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        Packet pk = (Packet)exchange.getIn().getHeader("doc");
        exchange.getIn().setBody(pk.toXML());
    }
}).to("stream:out");
{code} 

A pubsub and presence can be send like below. camel-xmpp does't take responsibility of creating these packets (we will need too many enpoint parameters for that). Please do let me know if you have a better way to do this.

{code:java} 
//Publish to a topic
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        String xmlpayLoad = "<entry xmlns='jabber:x:data'><data>" + exchange.getIn().getBody().toString() + "</data></entry>";
        String NAMESPACE = "http://jabber.org/protocol/pubsub";
        PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("itemid1", new SimplePayload("data", NAMESPACE, xmlpayLoad));
        PubSub p = new PubSub();
        p.setTo("pubsub.banl080161");
        p.setType(IQ.Type.SET);
        p.addExtension(new PublishItem<PayloadItem<?>>("topic1", item));
                        
        String str = p.toXML();
        System.out.println("Publishing to node 'topic1' withp this data: " + str);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&pubsub=true");
{code} 


{code:java} 
//send presence
from("stream:in?promptMessage=Enter something:").process( new Processor(){
    public void process(Exchange exchange) throws Exception {
        System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
        Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
        exchange.getIn().setBody(p);
    }
    })
.to("xmpp:user1@banl080161?password=pass1&presence=true");
{code} 

  
> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>         Attachments: Camel-xmpp-pubsub-presence.patch
>
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Donald Whytock (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=62407#action_62407 ] 

Donald Whytock commented on CAMEL-3195:
---------------------------------------

There are limitations in general to the existing XMPP endpoint.  It isn't triggered by presence or pubsub packets on input either.  Nor does it set headers on input, so one can't use a single endpoint for receiving from multiple sources.  In addition, XMPP recognizes an HTML element in the message body, but the endpoint only supplies the text element.

I'd like to suggest the following:

New endpoint parameters:
presence -- boolean -- Accept presence packets on input, default is false
pubsub -- boolean -- Accept pubsub packets on input, default is false
doc -- boolean -- Set a doc header on the IN message containing a Document form of the incoming packet; default is true if presence or pubsub are true, otherwise false

New input headers:
from
type
doc -- Document containing the inbound packet, if presence, pubsub or doc is set; message body still set with text element, if any

New output headers:
to
doc -- Document containing the outbound packet; overrides the message, ignores the message body

> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chandra Prakash Joshi updated CAMEL-3195:
-----------------------------------------

    Attachment: Camel-xmpp-pubsub-presence-v2.patch

- All the existing camel tests pass with this patch.
- Added some new JUnit tests. more to follow.
- Room based (MUC) and PubSub might not work together on same endpoint.


> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>         Attachments: Camel-xmpp-pubsub-presence-v2.patch
>
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CAMEL-3195) Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint

Posted by "Chandra Prakash Joshi (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/activemq/browse/CAMEL-3195?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chandra Prakash Joshi updated CAMEL-3195:
-----------------------------------------

    Attachment: Camel-xmpp-pubsub-presence.patch

Enhanced xmpp-camel to send/receive pubsub/presence packets.


> Allow camel to send custom xmpp Presence/PubSub packet to a xmpp endpoint
> -------------------------------------------------------------------------
>
>                 Key: CAMEL-3195
>                 URL: https://issues.apache.org/activemq/browse/CAMEL-3195
>             Project: Apache Camel
>          Issue Type: New Feature
>          Components: camel-xmpp
>            Reporter: Chandra Prakash Joshi
>         Attachments: Camel-xmpp-pubsub-presence.patch
>
>
> Claus Ibsen suggested that I should create a ticket for this new feature ([http://stackoverflow.com/questions/3645159/can-apache-camel-send-a-xmpp-presence-pubsub-packet-to-an-xmpp-endpoint])
> I need to receive an update published to a JMS topic, convert it to a XMPP packet (Presence packet or PubSub packet) and route it to an XMPP endpoint.
> I am using ActiveMQ as JMS provider and Apache camel as routing engine. given below is my route in Camel (to make things simple I read from system.in instead of a jms topic):
> {code:java} 
>      from("stream:in?promptMessage=Enter something:").process( new Processor(){
>         public void process(Exchange exchange) throws Exception {
>                 System.out.println("sending presence with message: " + exchange.getIn().getBody().toString());
>                 Presence p = new Presence(Type.available, exchange.getIn().getBody().toString(), 5, Mode.chat);
>                 exchange.getIn().setBody(p);
>             }
>             }).to("xmpp:user1@banl080161?password=pass1");
> {code}
> Idea is that user1@banl080161 should be able to send a custome presence packet having status as given from system.in. I am reading from system.in, making a presence packet, setting this packet in the exchange body and send this presence on behalf of user1@banl080161.
> Problem: nothing gets sent to XMPP server, I use PSI to see packets coming from user1@banl080161, user1@banl080161 comes online for sure but no custom presence message is received.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.