Example usage for javax.resource.spi.endpoint MessageEndpoint beforeDelivery

List of usage examples for javax.resource.spi.endpoint MessageEndpoint beforeDelivery

Introduction

In this page you can find the example usage for javax.resource.spi.endpoint MessageEndpoint beforeDelivery.

Prototype

void beforeDelivery(java.lang.reflect.Method method) throws NoSuchMethodException, ResourceException;

Source Link

Document

This is called by a resource adapter before a message is delivered.

Usage

From source file:me.jtalk.socketconnector.SocketResourceAdapter.java

private <T> void sendEndpoint(MessageEndpointFactory factory, Method target, T message) {
    try {// w  w  w.j  ava2s .  c o  m
        MessageEndpoint endpoint = factory.createEndpoint(null);
        endpoint.beforeDelivery(target);
        try {
            log.trace("Sending endpoint message to ''{}'': prepare", target.getName());

            if (message == null) {
                target.invoke(endpoint);
            } else {
                target.invoke(endpoint, message);
            }

            log.trace("Sending endpoint message to ''{}'': sent", target.getName());
        } catch (IllegalAccessException | InvocationTargetException e) {
            log.error("Exception on message endpoint invocation", e);
        }
        endpoint.afterDelivery();
        endpoint.release();
    } catch (UnavailableException e) {
        log.error("Message endpoint is unavailable", e);
    } catch (ResourceException | NoSuchMethodException e) {
        log.error("Exception on message endpoint processing", e);
    }
}