Search in sources :

Example 1 with KeyedDataQueue

use of com.ibm.as400.access.KeyedDataQueue in project camel by apache.

the class Jt400DataQueueService method start.

@Override
public void start() throws Exception {
    if (queue == null) {
        AS400 system = endpoint.getSystem();
        if (endpoint.isKeyed()) {
            queue = new KeyedDataQueue(system, endpoint.getObjectPath());
        } else {
            queue = new DataQueue(system, endpoint.getObjectPath());
        }
    }
    if (!queue.getSystem().isConnected(AS400.DATAQUEUE)) {
        LOG.info("Connecting to {}", endpoint);
        queue.getSystem().connectService(AS400.DATAQUEUE);
    }
}
Also used : BaseDataQueue(com.ibm.as400.access.BaseDataQueue) DataQueue(com.ibm.as400.access.DataQueue) KeyedDataQueue(com.ibm.as400.access.KeyedDataQueue) AS400(com.ibm.as400.access.AS400) KeyedDataQueue(com.ibm.as400.access.KeyedDataQueue)

Example 2 with KeyedDataQueue

use of com.ibm.as400.access.KeyedDataQueue in project camel by apache.

the class Jt400DataQueueConsumer method receive.

private Exchange receive(KeyedDataQueue queue, long timeout) throws Exception {
    String key = getEndpoint().getSearchKey();
    String searchType = getEndpoint().getSearchType().name();
    KeyedDataQueueEntry entry;
    if (timeout >= 0) {
        int seconds = (int) timeout / 1000;
        log.trace("Reading from data queue: {} with {} seconds timeout", queue.getName(), seconds);
        entry = queue.read(key, seconds, searchType);
    } else {
        log.trace("Reading from data queue: {} with no timeout", queue.getName());
        entry = queue.read(key, -1, searchType);
    }
    Exchange exchange = getEndpoint().createExchange();
    if (entry != null) {
        exchange.getIn().setHeader(Jt400Endpoint.SENDER_INFORMATION, entry.getSenderInformation());
        if (getEndpoint().getFormat() == Jt400Configuration.Format.binary) {
            exchange.getIn().setBody(entry.getData());
            exchange.getIn().setHeader(Jt400Endpoint.KEY, entry.getKey());
        } else {
            exchange.getIn().setBody(entry.getString());
            exchange.getIn().setHeader(Jt400Endpoint.KEY, entry.getKeyString());
        }
        return exchange;
    }
    return null;
}
Also used : Exchange(org.apache.camel.Exchange) KeyedDataQueueEntry(com.ibm.as400.access.KeyedDataQueueEntry)

Aggregations

AS400 (com.ibm.as400.access.AS400)1 BaseDataQueue (com.ibm.as400.access.BaseDataQueue)1 DataQueue (com.ibm.as400.access.DataQueue)1 KeyedDataQueue (com.ibm.as400.access.KeyedDataQueue)1 KeyedDataQueueEntry (com.ibm.as400.access.KeyedDataQueueEntry)1 Exchange (org.apache.camel.Exchange)1