I found a way, which seems to work for me.
The solution was to create a custom component which extends the NettyComponent.
The corresponing endpoint will have an reference to the used listener channel
(Consumer).
@Override
protected void doStart() throws Exception
{
super.doStart();
Field nettyServerBootstrapFactory =
GsPblConsumer.class.getSuperclass().getDeclaredField("nettyServerBootstrapFactory");
nettyServerBootstrapFactory.setAccessible(true);
Object nsbf = nettyServerBootstrapFactory.get(this);
Field channel = nsbf.getClass().getDeclaredField("channel");
channel.setAccessible(true);
channelToShare = (Channel) channel.get(nsbf);
getEndpoint().setSharedChannel(channelToShare);
}
This channel will be used for the Producer to send the messages.
@Override
public boolean process(Exchange exchange, AsyncCallback callback)
{
...
// get a channel from the pool
Channel existing;
try {
if (getConfiguration().isShareChannel() &&
getEndpoint().hasChannelToShare())
existing = getEndpoint().getSharedChannel();
else
existing = pool.borrowObject();
if (existing != null) {
LOG.trace("Got channel from pool {}", existing);
}
} catch (Exception e) {
exchange.setException(e);
callback.done(true);
return true;
}
...
}
Does anybody know a better solution?
Thanks,
Jörg
________________________________
If you reply to this email, your message will be added to the discussion below:
http://camel.465427.n5.nabble.com/publish-subscribe-with-camel-netty4-tp5801431p5802787.html
To unsubscribe from publish/subscribe with camel-netty4, click
here<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5801431&code=Sm9lcmcuSmFuc2VuQGluZm9ybS1zb2Z0d2FyZS5jb218NTgwMTQzMXwxNzQxNTY0MTky>.
NAML<http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>