...
Maven users will need to add the following dependency to their pom.xml
for this component:
Code Block |
---|
|
<dependency>
<groupId>org.apache-extras.camel<camel-extra</groupId>
<artifactId>camel-zeromq</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
|
URI format
Code Block |
---|
zeromq:(tcp|ipc)://hostname:port[?options]
|
Where hostname is the hostname or ip where the server will run.
Options
Div |
---|
class | confluenceTableSmall |
---|
|
Property | Default | Description |
---|
socketType
| none
| Choose from PULL, SUBSCRIBE for consumers, or PUSH, PUBLISH for producers | asyncConsumer
| true
| Sets the consumer to be async. | topics
| null
| Applicable for subscribers and publishers only. Determines which topics to subscribe or publish to. If not specified then the subscriber will subscribe to all messages. If not specified by a publisher then no topic will be prefixed to the message. Specify multiple topics by a comma separated list | messageIdEnabled
| false
| If enabled then camel-zeromq will add a unique UUID to each message as it is received | messageConvertor
| DefaultMessageConvertor
| The message convertor that is used to turn an exchange into a byte array for dispatch through zeromq. See later section. | highWaterMark
| -1
| By default, zeromq will keep messages in an in-memory buffer while waiting for clients to receive. The high water mark is the max number of messages to hold before throwing an exception. -1 sets to the zeromq default, 0 disables, and any positive value sets to that value. | linger
| -1
| By default, zeromq will wait for sending messages to be received before shutting down. Linger is the number of seconds to wait before force closing the socket. -1 sets to the zeromq default, 0 disables, and any positive value sets to that value. |
|
Wiki Markup |
---|
{div:class=confluenceTableSmall}
|| Property || Default || Description ||
| {{socketType}} | {{none}} | Choose from PULL, SUBSCRIBE for consumers, or PUSH, PUBLISH for producers |
| {{asyncConsumer}} | {{true}} | Sets the consumer to be async. |
| {{topics}} | {{null}} | Applicable for subscribers and publishers only. Determines which topics to subscribe or publish to. If not specified then the subscriber will subscribe to all messages. If not specified by a publisher then no topic will be prefixed to the message. Specify multiple topics by a comma separated list |
| {{messageIdEnabled}} | {{false}} | If enabled then camel-zeromq will add a unique UUID to each message as it is received |
| {{messageConvertor}} | {{DefaultMessageConvertor}} | The message convertor that is used to turn an exchange into a byte array for dispatch through zeromq. See later section. |
| {{highWaterMark}} | {{-1}} | By default, zeromq will keep messages in an in-memory buffer while waiting for clients to receive. The high water mark is the max number of messages to hold before throwing an exception. -1 sets to the zeromq default, 0 disables, and any positive value sets to that value. |
| {{linger}} | {{-1}} | By default, zeromq will wait for sending messages to be received before shutting down. Linger is the number of seconds to wait before force closing the socket. -1 sets to the zeromq default, 0 disables, and any positive value sets to that value. |
{div} |
The follwing headers are set on exchanges during message transport.
...
To receive all messages from a publisher, and then print those to a logger:
Code Block |
---|
from("zeromq:tcp://127.0.0.1:5555").process(someLoggingProcessor);
|
To broadcast a message every second on three topics:
Code Block |
---|
from("timer://foo?fixedRate=true&period=10").process(new Processor() {
List<String> asList = Arrays.asList("coldplay", "keane", "jethro tull", "jack bruce", "elton john", "kate bush");
@Override
public void process(Exchange exchange) throws Exception {
Collections.shuffle(asList);
exchange.getIn().setBody(asList.get(0));
}
}).to("zeromq:tcp://127.0.0.1:5556?socketType=PUBLISH&topics=bands,musicians,singers");
|