use of org.apache.cxf.workqueue.WorkQueueManager in project jbossws-cxf by jbossws.
the class UDPDestination method activate.
protected void activate() {
WorkQueueManager queuem = bus.getExtension(WorkQueueManager.class);
queue = queuem.getNamedWorkQueue("udp-transport");
if (queue == null) {
queue = queuem.getAutomaticWorkQueue();
}
try {
URI uri = new URI(this.getAddress().getAddress().getValue());
InetSocketAddress isa = null;
if (StringUtils.isEmpty(uri.getHost())) {
String s = uri.getSchemeSpecificPart();
if (s.startsWith("//:")) {
s = s.substring(3);
}
if (s.indexOf('/') != -1) {
s = s.substring(0, s.indexOf('/'));
}
int port = Integer.parseInt(s);
isa = new InetSocketAddress(port);
} else {
isa = new InetSocketAddress(uri.getHost(), uri.getPort());
}
DatagramSocket s;
if (isa.getAddress().isMulticastAddress()) {
s = new MulticastSocket(null);
((MulticastSocket) s).setTimeToLive(1);
s.bind(new InetSocketAddress(isa.getPort()));
((MulticastSocket) s).joinGroup(isa.getAddress());
} else {
s = new DatagramSocket(null);
s.bind(new InetSocketAddress(isa.getAddress(), isa.getPort()));
}
s.setReuseAddress(true);
s.setReceiveBufferSize(64 * 1024);
s.setSendBufferSize(64 * 1024);
socket = s;
queue.execute(new SocketListener());
} catch (Exception ex) {
LOG.log(Level.SEVERE, ex.toString());
throw new RuntimeException(ex);
}
}
use of org.apache.cxf.workqueue.WorkQueueManager in project tomee by apache.
the class OSGIBusListener method initComplete.
public void initComplete() {
ManagedWorkQueueList wqList = bus.getExtension(ManagedWorkQueueList.class);
if (wqList != null) {
WorkQueueManager manager = bus.getExtension(WorkQueueManager.class);
wqList.addAllToWorkQueueManager(manager);
}
registerBusAsService();
}
use of org.apache.cxf.workqueue.WorkQueueManager in project cxf by apache.
the class UDPConduit method dataReceived.
private void dataReceived(Message message, IoBuffer buf, boolean async, boolean multi) {
synchronized (message.getExchange()) {
if (message.getExchange().getInMessage() == null) {
final Message inMessage = new MessageImpl();
IoSessionInputStream ins = new IoSessionInputStream(buf);
inMessage.setContent(InputStream.class, ins);
inMessage.put(IoSessionInputStream.class, ins);
message.getExchange().setInMessage(inMessage);
inMessage.setExchange(message.getExchange());
Map<String, Object> mp = null;
if (multi) {
mp = new HashMap<>(message.getExchange());
}
if (async) {
WorkQueueManager queuem = bus.getExtension(WorkQueueManager.class);
WorkQueue queue = queuem.getNamedWorkQueue("udp-conduit");
if (queue == null) {
queue = queuem.getAutomaticWorkQueue();
}
queue.execute(new Runnable() {
public void run() {
incomingObserver.onMessage(inMessage);
}
});
} else {
incomingObserver.onMessage(inMessage);
if (!message.getExchange().isSynchronous() || multi) {
message.getExchange().setInMessage(null);
message.getExchange().setInFaultMessage(null);
}
}
if (mp != null) {
Collection<String> s = new ArrayList<>(message.getExchange().keySet());
for (String s2 : s) {
message.getExchange().remove(s2);
}
message.getExchange().putAll(mp);
}
} else {
IoSessionInputStream ins = message.getExchange().getInMessage().get(IoSessionInputStream.class);
ins.setBuffer(buf);
}
}
}
use of org.apache.cxf.workqueue.WorkQueueManager in project cxf by apache.
the class UDPDestination method activate.
protected void activate() {
WorkQueueManager queuem = bus.getExtension(WorkQueueManager.class);
queue = queuem.getNamedWorkQueue("udp-transport");
if (queue == null) {
queue = queuem.getAutomaticWorkQueue();
}
try {
URI uri = new URI(this.getAddress().getAddress().getValue());
InetSocketAddress isa = null;
if (StringUtils.isEmpty(uri.getHost())) {
String s = uri.getSchemeSpecificPart();
if (s.startsWith("//:")) {
s = s.substring(3);
}
if (s.indexOf('/') != -1) {
s = s.substring(0, s.indexOf('/'));
}
int port = Integer.parseInt(s);
isa = new InetSocketAddress(port);
} else {
isa = new InetSocketAddress(uri.getHost(), uri.getPort());
}
if (isa.getAddress().isMulticastAddress()) {
// ouch...
MulticastSocket socket = new MulticastSocket(null);
socket.setReuseAddress(true);
socket.setReceiveBufferSize(64 * 1024);
socket.setSendBufferSize(64 * 1024);
socket.setTimeToLive(1);
socket.setLoopbackMode(false);
socket.bind(new InetSocketAddress(isa.getPort()));
socket.setNetworkInterface(findNetworkInterface());
socket.joinGroup(isa.getAddress());
mcast = socket;
queue.execute(new MCastListener());
} else {
acceptor = new NioDatagramAcceptor();
acceptor.setHandler(new UDPIOHandler());
acceptor.setDefaultLocalAddress(isa);
DatagramSessionConfig dcfg = acceptor.getSessionConfig();
dcfg.setReadBufferSize(64 * 1024);
dcfg.setSendBufferSize(64 * 1024);
dcfg.setReuseAddress(true);
acceptor.bind();
}
} catch (Exception ex) {
ex.printStackTrace();
throw new RuntimeException(ex);
}
}
use of org.apache.cxf.workqueue.WorkQueueManager in project cxf by apache.
the class JMSFactory method createWorkQueueExecutor.
/**
* Get workqueue from workqueue manager. Return an executor that will never reject messages and
* instead block when all threads are used.
*
* @param bus
* @param name
* @return
*/
public static Executor createWorkQueueExecutor(Bus bus, String name) {
WorkQueueManager manager = bus.getExtension(WorkQueueManager.class);
if (manager != null) {
AutomaticWorkQueue workQueue1 = manager.getNamedWorkQueue(name);
final WorkQueue workQueue = (workQueue1 == null) ? manager.getAutomaticWorkQueue() : workQueue1;
return new Executor() {
@Override
public void execute(Runnable command) {
workQueue.execute(command, 0);
}
};
}
return Executors.newFixedThreadPool(20);
}
Aggregations