本文整理汇总了Java中org.apache.cxf.workqueue.WorkQueueManager类的典型用法代码示例。如果您正苦于以下问题:Java WorkQueueManager类的具体用法?Java WorkQueueManager怎么用?Java WorkQueueManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorkQueueManager类属于org.apache.cxf.workqueue包,在下文中一共展示了WorkQueueManager类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: echo
import org.apache.cxf.workqueue.WorkQueueManager; //导入依赖的package包/类
@WebMethod
public String echo(String input)
{
//this is just a verification, so going the dirty way...
Bus bus = EndpointAssociation.getEndpoint().getService().getDeployment().getAttachment(BusHolder.class).getBus();
AutomaticWorkQueue queue = bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
Long qs = null;
Integer it = null;
try
{
qs = (Long) queue.getClass().getMethod("getMaxSize").invoke(queue);
it = (Integer) queue.getClass().getMethod("getHighWaterMark").invoke(queue);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
if (qs != 10)
{
throw new RuntimeException("Expected max queue size '10' but got '" + qs + "'!");
}
if (it != 8)
{
throw new RuntimeException("Expected highWaterMark '8' but got '" + it + "'!");
}
Logger.getLogger(this.getClass()).info("echo: " + input);
count.incrementAndGet();
return input;
}
示例2: registerZMQListener
import org.apache.cxf.workqueue.WorkQueueManager; //导入依赖的package包/类
private void registerZMQListener(EndpointConfig endpointConfig,
final MessageListener messageListener,
Bus bus,
final ZMQ.Context zmqContext) {
WorkQueueManager queueManager = bus.getExtension(WorkQueueManager.class);
final Executor executor = queueManager.getNamedWorkQueue("zmq-transport") != null ? queueManager.getNamedWorkQueue("zmq-transport") : queueManager.getAutomaticWorkQueue();
final ZMQ.Socket zmqSocket = ZMQResourceFactory.createSocket(endpointConfig, zmqContext);
final ZMQ.Poller poller = ZMQResourceFactory.createPoller(zmqSocket, zmqContext);
executor.execute(new Runnable() {
@Override
public void run() {
boolean isContextTerm = false;
while (!isContextTerm) {
poller.poll();
final byte[] message = ZMQUtils.receiveMessage(zmqSocket);
if (message != null) {
if (zmqSocket.getType() == ZMQ.REP) {
messageListener.onMessage(message, zmqSocket);
} else {
executor.execute(new Runnable() {
public void run() {
messageListener.onMessage(message, zmqSocket);
}
});
}
} else {
isContextTerm = true;
}
}
}
});
}
示例3: asyncInvokeFromWorkQueue
import org.apache.cxf.workqueue.WorkQueueManager; //导入依赖的package包/类
protected void asyncInvokeFromWorkQueue(final org.apache.camel.Exchange exchange) throws IOException {
Runnable runnable = new Runnable() {
public void run() {
try {
syncInvoke(exchange);
} catch (Throwable e) {
((PhaseInterceptorChain)outMessage.getInterceptorChain()).abort();
outMessage.setContent(Exception.class, e);
((PhaseInterceptorChain)outMessage.getInterceptorChain()).unwind(outMessage);
MessageObserver mo = outMessage.getInterceptorChain().getFaultObserver();
if (mo == null) {
mo = outMessage.getExchange().get(MessageObserver.class);
}
mo.onMessage(outMessage);
}
}
};
try {
Executor ex = outMessage.getExchange().get(Executor.class);
if (ex != null) {
outMessage.getExchange().put(Executor.class.getName()
+ ".USING_SPECIFIED", Boolean.TRUE);
ex.execute(runnable);
} else {
WorkQueueManager mgr = outMessage.getExchange().get(Bus.class)
.getExtension(WorkQueueManager.class);
AutomaticWorkQueue qu = mgr.getNamedWorkQueue("camel-cxf-conduit");
if (qu == null) {
qu = mgr.getAutomaticWorkQueue();
}
// need to set the time out somewhere
qu.execute(runnable);
}
} catch (RejectedExecutionException rex) {
if (!hasLoggedAsyncWarning) {
LOG.warn("Executor rejected background task to retrieve the response. Suggest increasing the workqueue settings.");
hasLoggedAsyncWarning = true;
}
LOG.info("Executor rejected background task to retrieve the response, running on current thread.");
syncInvoke(exchange);
}
}