RE: send same message to multiple, not all, websocket clients

2016-10-18 Thread shemeem . sp
Hi Mark,
you have to keep connection keys from each client in a map or list,
then you need to send same data to the producer with different connection key.

here is how you can get the connection key from each client. whenever a client 
makes a connection with your websocket consumer you will get a connection key.

Apache camel websocket consumer example.
 from("direct:Consumer1")
.process(new Processor() {
 public void process(Exchange exchange) throws Exception {
   Map headers=exchange.getIn().getHeaders();
//you will get a unique connection key from the exchange header.This would 
be unique for each client.
//store this key somewhere, to send messages to particular client.
String 
uniqueConnectionKey=headers.get("websocket.connectionKey").toString();
  //you can get message from the client like below.
  String dataFromClient=exchange.getIn().getBody().toString();
  
   }
}).end();

Apache camel websocket producer example:
  from("direct:Producer1").
  //we will use this connectionKey for uniquely identifying each connection 
from the client.
  setHeader(WebsocketConstants.CONNECTION_KEY, header("connectionKey")).
  to("websocket://{host}:{port}/camel-websocket?sendToAll=false").end();

here is the sample for producer template.
ProducerTemplate template=camelContext.createProducerTemplate();

repeat this step with same message and different connection key:
template.sendBodyAndHeader("direct:Producer1", {message}, "connectionKey", 
{connectionkey});

I hope this would help

-Original Message-
From: "Mark" 
Sent: Tuesday, October 18, 2016 10:51am
To: users@camel.apache.org
Subject: send same message to multiple, not all, websocket clients

I am receiving messages of data that I am processing with Camel, similar to
a chat system.  Clients may "subscribe" to the data feed which will require
me to send the messages to the clients that subscribe to that message type
over websockets.  How can I implement this websocket communication using
Camel since the current implementation only allows for one connection key
per message?  Would I somehow duplicate the message and set a different
connection key for each message?




camel websocket - java.net.BindException: Address already in use: bind

2015-08-04 Thread Shemeem
Hi All,
I am using apache camel websocket in OSGI enviromnet(apache karaf
container). I am not able to redeploy my bundle with websocket route. When I
am trying the same, I am getting the following exception in log:

Caused by: org.apache.camel.FailedToCreateProducerException: Failed to
create Producer for endpoint:
Endpoint[websocket://{host}:{port}/camel-websocket?maxIdle
Time=300sendToAll=false]. Reason: java.net.BindException: Address
already in use: bind

This error clearly says that, the port which I am using is preoccupied. 
Here, my question is how do I release the port in camel websocket??
I am stoping the camel context and websocket using the below code, in the
bundle stop method, inside the bundle activator class.

WebsocketComponent wc
=camelConetxtImpl.getCamelConetxt().getComponent(websocket,
WebsocketComponent.class);

wc.doStop();

As well as, I amstoping the camel context also.

But this is not working for me. Every time, I have to restart the karaf,
in-order to solve this issue.

Please guide me on this issue. :) Is there any other way to release the
port?? 

Thanks in advance
Shemeem SP 



--
View this message in context: 
http://camel.465427.n5.nabble.com/camel-websocket-java-net-BindException-Address-already-in-use-bind-tp5770274.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: is it dependency issue?

2015-05-21 Thread Shemeem
Hi,

What is your OSGI container? 
Is it Karaf? If so, you have to install camel in karaf (even though, you
have provided dependency in camel ) with the below command :

karaf@root features:chooseurl camel 2.12.1 (provide the version you want)
karaf@root features:install camel

These camel commands may have little difference based on your karaf version.
 
This is how you should initialize your camel context for OSGI bundles in
case of Java DSL.

OsgiServiceRegistry reg = new OsgiServiceRegistry(bundleContext); 

context=new OsgiDefaultCamelContext(bundleContext, reg); 




--
View this message in context: 
http://camel.465427.n5.nabble.com/is-it-dependency-issue-tp5767374p5767390.html
Sent from the Camel - Users mailing list archive at Nabble.com.