use of org.apache.cxf.workqueue.WorkQueue 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.WorkQueue 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