当前位置: 首页>>代码示例>>Java>>正文


Java Exchange.setInMessage方法代码示例

本文整理汇总了Java中org.apache.cxf.message.Exchange.setInMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Exchange.setInMessage方法的具体用法?Java Exchange.setInMessage怎么用?Java Exchange.setInMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cxf.message.Exchange的用法示例。


在下文中一共展示了Exchange.setInMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupCamelDestination

import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
public CamelDestination setupCamelDestination(EndpointInfo endpointInfo, boolean send) throws IOException {
    ConduitInitiator conduitInitiator = EasyMock.createMock(ConduitInitiator.class);
    CamelDestination camelDestination = new CamelDestination(context, bus, conduitInitiator, endpointInfo);
    if (send) {
        // setMessageObserver
        observer = new MessageObserver() {
            public void onMessage(Message m) {
                Exchange exchange = new ExchangeImpl();
                exchange.setInMessage(m);
                m.setExchange(exchange);
                destMessage = m;
            }
        };
        camelDestination.setMessageObserver(observer);
    }
    return camelDestination;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CamelDestinationTest.java

示例2: getTestExchange

import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
private Exchange getTestExchange() {
   Exchange exchange = new ExchangeImpl();
   Message message = new MessageImpl();
   message.setExchange(exchange);
   exchange.setInMessage(message);
   exchange.put(BindingOperationInfo.class, new BindingOperationInfo());
   Service service = new ServiceImpl();
   MethodDispatcher md = new MethodDispatcher() {
      @Override
      public Method getMethod(BindingOperationInfo op) {
         return this.getClass().getMethods()[0];
      }
      @Override
      public BindingOperationInfo getBindingOperation(Method m, Endpoint endpoint) {
         return null;
      }
      @Override
      public void bind(OperationInfo o, Method... methods) {
      }
   };
   service.put(MethodDispatcher.class.getName(), md);
   exchange.put(Service.class, service);
   return exchange;
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:25,代码来源:JBossWSInvokerTest.java

示例3: testRoundTripDestination

import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
@Test
public void testRoundTripDestination() throws Exception {

    inMessage = null;
    EndpointInfo conduitEpInfo = new EndpointInfo();
    conduitEpInfo.setAddress("camel://direct:Producer");
    // set up the conduit send to be true
    CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
    final Message outMessage = new MessageImpl();

    endpointInfo.setAddress("camel://direct:EndpointA");
    final CamelDestination destination = setupCamelDestination(endpointInfo, true);

    // set up MessageObserver for handling the conduit message
    MessageObserver observer = new MessageObserver() {
        public void onMessage(Message m) {
            try {
                Exchange exchange = new ExchangeImpl();
                exchange.setInMessage(m);
                m.setExchange(exchange);
                verifyReceivedMessage(m, "HelloWorld");
                //verifyHeaders(m, outMessage);
                // setup the message for
                Conduit backConduit;
                backConduit = getBackChannel(destination, m);
                // wait for the message to be got from the conduit
                Message replyMessage = new MessageImpl();
                sendoutMessage(backConduit, replyMessage, true, "HelloWorld Response");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
    error.expectedMessageCount(0);
    //this call will active the camelDestination
    destination.setMessageObserver(observer);
    // set is one way false for get response from destination
    // need to use another thread to send the request message
    sendoutMessage(conduit, outMessage, false, "HelloWorld");
    // wait for the message to be got from the destination,
    // create the thread to handler the Destination incoming message

    verifyReceivedMessage(inMessage, "HelloWorld Response");
    error.assertIsSatisfied();
    destination.shutdown();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:48,代码来源:CamelDestinationTest.java

示例4: testRoundTripDestinationWithFault

import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
@Test
public void testRoundTripDestinationWithFault() throws Exception {

    inMessage = null;
    EndpointInfo conduitEpInfo = new EndpointInfo();
    conduitEpInfo.setAddress("camel://direct:Producer");
    // set up the conduit send to be true
    CamelConduit conduit = setupCamelConduit(conduitEpInfo, true, false);
    final Message outMessage = new MessageImpl();

    endpointInfo.setAddress("camel://direct:EndpointA");
    final CamelDestination destination = setupCamelDestination(endpointInfo, true);
    destination.setCheckException(true);

    // set up MessageObserver for handling the conduit message
    MessageObserver observer = new MessageObserver() {
        public void onMessage(Message m) {
            try {
                Exchange exchange = new ExchangeImpl();
                exchange.setInMessage(m);
                m.setExchange(exchange);
                verifyReceivedMessage(m, "HelloWorld");
                //verifyHeaders(m, outMessage);
                // setup the message for
                Conduit backConduit;
                backConduit = getBackChannel(destination, m);
                // wait for the message to be got from the conduit
                Message replyMessage = new MessageImpl();
                replyMessage.setContent(Exception.class, new RuntimeCamelException());
                sendoutMessage(backConduit, replyMessage, true, "HelloWorld Fault");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    };
    
    MockEndpoint error = context.getEndpoint("mock:error", MockEndpoint.class);
    error.expectedMessageCount(1);
    
    //this call will active the camelDestination
    destination.setMessageObserver(observer);
    // set is one way false for get response from destination
    // need to use another thread to send the request message
    sendoutMessage(conduit, outMessage, false, "HelloWorld");
    // wait for the message to be got from the destination,
    // create the thread to handler the Destination incoming message

    verifyReceivedMessage(inMessage, "HelloWorld Fault");
    error.assertIsSatisfied();
    
    destination.shutdown();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:53,代码来源:CamelDestinationTest.java

示例5: run

import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
public void run()
{
   while (true)
   {
      if (socket == null)
      {
         return;
      }
      try
      {
         byte bytes[] = new byte[64 * 1024];
         final DatagramPacket p = new DatagramPacket(bytes, bytes.length);
         socket.receive(p);

         LoadingByteArrayOutputStream out = new LoadingByteArrayOutputStream()
         {
            public void close() throws IOException
            {
               super.close();
               final DatagramPacket p2 = new DatagramPacket(getRawBytes(), 0, this.size(), p.getSocketAddress());
               socket.send(p2);
            }
         };

         UDPConnectionInfo info = new UDPConnectionInfo(out, new ByteArrayInputStream(bytes, 0, p.getLength()));

         final MessageImpl m = new MessageImpl();
         final Exchange exchange = new ExchangeImpl();
         exchange.setDestination(UDPDestination.this);
         m.setDestination(UDPDestination.this);
         exchange.setInMessage(m);
         m.setContent(InputStream.class, info.in);
         m.put(UDPConnectionInfo.class, info);
         queue.execute(new Runnable()
         {
            public void run()
            {
               getMessageObserver().onMessage(m);
            }
         });
      }
      catch (IOException e)
      {
         if (socket != null) {
            LOG.log(Level.SEVERE, e.toString());
         }
      }
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:50,代码来源:UDPDestination.java

示例6: sendExchange

import org.apache.cxf.message.Exchange; //导入方法依赖的package包/类
public void sendExchange(final Exchange exchange, final byte[] request) {
    LOG.log(Level.FINE, "ZMQConduit send message");

    final Message outMessage = exchange.getOutMessage() == null
            ? exchange.getOutFaultMessage()
            : exchange.getOutMessage();

    if (outMessage == null) {
        throw new RuntimeException("Exchange to be sent has no outMessage");
    }

    synchronized (exchange) {
        try {
            ZMQUtils.sendMessage(zmqSocket, request);
        }
        catch (ZMQException e) {
            if (e.getErrorCode() == ZMQURIConstants.ERR_EFSM) {
                LOG.log(Level.WARNING, "The operation can not be executed because the socket is not in correct state. Creating new socket and retrying operation...");
                zmqSocket.close();
                zmqSocket = ZMQResourceFactory.createSocket(endpointConfig, zmqContext);
                ZMQUtils.sendMessage(zmqSocket, request);
            }
            else {
                throw e;
            }

        }

        byte[] reply;

        if (isOneway(exchange) || !(endpointConfig.getSocketType().equals(ZMQURIConstants.SocketType.REQ))) {

            if (endpointConfig.getSocketType().equals(ZMQURIConstants.SocketType.REQ)) {
                reply = ZMQUtils.receiveMessage(zmqSocket);
                if ((reply.length == 1 && reply[0] == 0) || !doProcessResponse(outMessage)) {
                    return;
                }
            } else {
                return;
            }

        } else {
            reply = ZMQUtils.receiveMessage(zmqSocket);
        }

        Message inMessage = new MessageImpl();
        exchange.setInMessage(inMessage);
        inMessage.setContent(InputStream.class, new ByteArrayInputStream(reply));
        if (exchange.isSynchronous()) {
            exchange.notifyAll();
        }
    }

    if (incomingObserver != null) {
        incomingObserver.onMessage(exchange.getInMessage());
    }

}
 
开发者ID:claudemamo,项目名称:cxf-rt-transports-zeromq,代码行数:59,代码来源:ZMQConduit.java


注:本文中的org.apache.cxf.message.Exchange.setInMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。