Search in sources :

Example 1 with Oneway

use of org.apache.cxf.jaxrs.ext.Oneway in project cxf by apache.

the class JMSBookStore method onewayRequest.

@PUT
@Path("/oneway")
@Consumes()
@Oneway
public void onewayRequest(Book book) throws Exception {
    Context ctx = getContext();
    ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
    Destination replyToDestination = (Destination) ctx.lookup("dynamicQueues/test.jmstransport.response");
    Connection connection = null;
    try {
        connection = factory.createConnection();
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        postOneWayBook(session, replyToDestination, book);
        session.close();
    } finally {
        try {
            if (connection != null) {
                connection.stop();
                connection.close();
            }
        } catch (JMSException ex) {
        // ignore
        }
    }
}
Also used : Context(javax.naming.Context) JAXBContext(javax.xml.bind.JAXBContext) InitialContext(javax.naming.InitialContext) Destination(javax.jms.Destination) ConnectionFactory(javax.jms.ConnectionFactory) Connection(javax.jms.Connection) JMSException(javax.jms.JMSException) Session(javax.jms.Session) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Oneway(org.apache.cxf.jaxrs.ext.Oneway) PUT(javax.ws.rs.PUT)

Example 2 with Oneway

use of org.apache.cxf.jaxrs.ext.Oneway in project tesb-rt-se by Talend.

the class JMSHttpBookStore method oneWayRequest.

@PUT
@Oneway
public void oneWayRequest(Book book) throws Exception {
    // printRequestTransport();
    Connection connection = null;
    try {
        Context ctx = getContext();
        ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
        Destination replyToDestination = (Destination) ctx.lookup("dynamicQueues/test.jmstransport.response");
        connection = factory.createConnection("tesb", "tesb");
        connection.start();
        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        postOneWayBook(session, replyToDestination, book);
        session.close();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    } finally {
        try {
            if (connection != null) {
                connection.stop();
                connection.close();
            }
        } catch (JMSException ex) {
        // ignore
        }
    }
}
Also used : Context(javax.naming.Context) JAXBContext(javax.xml.bind.JAXBContext) InitialContext(javax.naming.InitialContext) Destination(javax.jms.Destination) ConnectionFactory(javax.jms.ConnectionFactory) Connection(javax.jms.Connection) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException) Session(javax.jms.Session) Oneway(org.apache.cxf.jaxrs.ext.Oneway) PUT(javax.ws.rs.PUT)

Aggregations

Connection (javax.jms.Connection)2 ConnectionFactory (javax.jms.ConnectionFactory)2 Destination (javax.jms.Destination)2 JMSException (javax.jms.JMSException)2 Session (javax.jms.Session)2 Context (javax.naming.Context)2 InitialContext (javax.naming.InitialContext)2 PUT (javax.ws.rs.PUT)2 JAXBContext (javax.xml.bind.JAXBContext)2 Oneway (org.apache.cxf.jaxrs.ext.Oneway)2 Consumes (javax.ws.rs.Consumes)1 Path (javax.ws.rs.Path)1