Search in sources :

Example 1 with IFSAServiceName

use of com.ing.ifsa.IFSAServiceName in project iaf by ibissource.

the class PullingIfsaProviderListener method open.

public void open() throws ListenerException {
    try {
        openService();
        IFSAServicesProvided services = getServiceQueue().getIFSAServicesProvided();
        for (int i = 0; i < services.getNumberOfServices(); i++) {
            IFSAServiceName service = services.getService(i);
            String protocol = (service.IsFireAndForgetService() ? "Fire and Forget" : "Request/Reply");
            log.info(getLogPrefix() + "providing ServiceName [" + service.getServiceName() + "] ServiceGroup [" + service.getServiceGroup() + "] protocol [" + protocol + "] ServiceVersion [" + service.getServiceVersion() + "]");
        }
    } catch (Exception e) {
        throw new ListenerException(getLogPrefix(), e);
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) IFSAServiceName(com.ing.ifsa.IFSAServiceName) IfsaException(nl.nn.adapterframework.extensions.ifsa.IfsaException) ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) JMSException(javax.jms.JMSException) IFSAServicesProvided(com.ing.ifsa.IFSAServicesProvided)

Example 2 with IFSAServiceName

use of com.ing.ifsa.IFSAServiceName in project iaf by ibissource.

the class PullingIfsaProviderListener method getIdFromRawMessage.

/**
 * Extracts ID-string from message obtained from {@link #getRawMessage(Map)}.
 * Puts also the following parameters  in the threadContext:
 * <ul>
 *   <li>id</li>
 *   <li>cid</li>
 *   <li>timestamp</li>
 *   <li>replyTo</li>
 *   <li>messageText</li>
 *   <li>fullIfsaServiceName</li>
 *   <li>ifsaServiceName</li>
 *   <li>ifsaGroup</li>
 *   <li>ifsaOccurrence</li>
 *   <li>ifsaVersion</li>
 * </ul>
 * @return ID-string of message for adapter.
 */
public String getIdFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
    IFSAMessage message = null;
    if (rawMessage instanceof IMessageWrapper) {
        return getIdFromWrapper((IMessageWrapper) rawMessage, threadContext);
    }
    try {
        message = (IFSAMessage) rawMessage;
    } catch (ClassCastException e) {
        log.error(getLogPrefix() + "message received was not of type IFSAMessage, but [" + rawMessage.getClass().getName() + "]", e);
        return null;
    }
    String mode = "unknown";
    String id = "unset";
    String cid = "unset";
    Date tsSent = null;
    Destination replyTo = null;
    String messageText = null;
    String fullIfsaServiceName = null;
    IFSAServiceName requestedService = null;
    String ifsaServiceName = null, ifsaGroup = null, ifsaOccurrence = null, ifsaVersion = null;
    try {
        if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) {
            mode = "NON_PERSISTENT";
        } else if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) {
            mode = "PERSISTENT";
        }
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        id = message.getJMSMessageID();
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        cid = message.getJMSCorrelationID();
        if (cid == null) {
            cid = id;
            log.debug("Setting correlation ID to MessageId");
        }
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        long lTimeStamp = message.getJMSTimestamp();
        tsSent = new Date(lTimeStamp);
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        replyTo = message.getJMSReplyTo();
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        messageText = ((TextMessage) message).getText();
    } catch (Throwable ignore) {
    }
    // --------------------------
    try {
        fullIfsaServiceName = message.getServiceString();
        requestedService = message.getService();
        ifsaServiceName = requestedService.getServiceName();
        ifsaGroup = requestedService.getServiceGroup();
        ifsaOccurrence = requestedService.getServiceOccurance();
        ifsaVersion = requestedService.getServiceVersion();
    } catch (JMSException e) {
        log.error(getLogPrefix() + "got error getting serviceparameter", e);
    }
    if (log.isDebugEnabled()) {
        log.debug(getLogPrefix() + "got message for [" + fullIfsaServiceName + "] with JMSDeliveryMode=[" + mode + "] \n  JMSMessageID=[" + id + "] \n  JMSCorrelationID=[" + cid + "] \n  ifsaServiceName=[" + ifsaServiceName + "] \n  ifsaGroup=[" + ifsaGroup + "] \n  ifsaOccurrence=[" + ifsaOccurrence + "] \n  ifsaVersion=[" + ifsaVersion + "] \n  Timestamp Sent=[" + DateUtils.format(tsSent) + "] \n  ReplyTo=[" + ((replyTo == null) ? "none" : replyTo.toString()) + "] \n  MessageHeaders=[" + displayHeaders(message) + "\n" + "] \n  Message=[" + message.toString() + "\n]");
    }
    PipeLineSessionBase.setListenerParameters(threadContext, id, cid, null, tsSent);
    threadContext.put("timestamp", tsSent);
    threadContext.put("replyTo", ((replyTo == null) ? "none" : replyTo.toString()));
    threadContext.put("messageText", messageText);
    threadContext.put("fullIfsaServiceName", fullIfsaServiceName);
    threadContext.put("ifsaServiceName", ifsaServiceName);
    threadContext.put("ifsaGroup", ifsaGroup);
    threadContext.put("ifsaOccurrence", ifsaOccurrence);
    threadContext.put("ifsaVersion", ifsaVersion);
    Map udz = (Map) message.getIncomingUDZObject();
    if (udz != null) {
        String contextDump = "ifsaUDZ:";
        for (Iterator it = udz.keySet().iterator(); it.hasNext(); ) {
            String key = (String) it.next();
            String value = (String) udz.get(key);
            contextDump = contextDump + "\n " + key + "=[" + value + "]";
            threadContext.put(key, value);
        }
        if (log.isDebugEnabled()) {
            log.debug(getLogPrefix() + contextDump);
        }
    }
    return id;
}
Also used : Destination(javax.jms.Destination) IMessageWrapper(nl.nn.adapterframework.core.IMessageWrapper) IFSAMessage(com.ing.ifsa.IFSAMessage) IFSAServiceName(com.ing.ifsa.IFSAServiceName) Iterator(java.util.Iterator) JMSException(javax.jms.JMSException) HashMap(java.util.HashMap) Map(java.util.Map) Date(java.util.Date)

Example 3 with IFSAServiceName

use of com.ing.ifsa.IFSAServiceName in project iaf by ibissource.

the class PushingIfsaProviderListener method getIdFromRawMessage.

/**
 * Extracts ID-string from message obtained from {@link #getRawMessage(Map)}.
 * Puts also the following parameters  in the threadContext:
 * <ul>
 *   <li>id</li>
 *   <li>cid</li>
 *   <li>timestamp</li>
 *   <li>replyTo</li>
 *   <li>messageText</li>
 *   <li>fullIfsaServiceName</li>
 *   <li>ifsaServiceName</li>
 *   <li>ifsaGroup</li>
 *   <li>ifsaOccurrence</li>
 *   <li>ifsaVersion</li>
 *   <li>ifsaBifName</li>
 *   <li>ifsaBtcData</li>
 * </ul>
 * @return ID-string of message for adapter.
 */
public String getIdFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
    IFSAMessage message = null;
    if (rawMessage instanceof IMessageWrapper) {
        return getIdFromWrapper((IMessageWrapper) rawMessage, threadContext);
    }
    try {
        message = (IFSAMessage) rawMessage;
    } catch (ClassCastException e) {
        log.error(getLogPrefix() + "message received was not of type IFSAMessage, but [" + rawMessage.getClass().getName() + "]", e);
        return null;
    }
    String mode = "unknown";
    String id = "unset";
    String cid = "unset";
    Date tsSent = null;
    Destination replyTo = null;
    String messageText = null;
    String fullIfsaServiceName = null;
    IFSAServiceName requestedService = null;
    String ifsaServiceName = null, ifsaGroup = null, ifsaOccurrence = null, ifsaVersion = null;
    try {
        if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) {
            mode = "NON_PERSISTENT";
        } else if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) {
            mode = "PERSISTENT";
        }
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        id = message.getJMSMessageID();
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        cid = message.getJMSCorrelationID();
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        long lTimeStamp = message.getJMSTimestamp();
        tsSent = new Date(lTimeStamp);
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        replyTo = message.getJMSReplyTo();
    } catch (JMSException ignore) {
    }
    // --------------------------
    try {
        messageText = ((TextMessage) message).getText();
    } catch (Throwable ignore) {
    }
    // --------------------------
    try {
        fullIfsaServiceName = message.getServiceString();
        requestedService = message.getService();
        ifsaServiceName = requestedService.getServiceName();
        ifsaGroup = requestedService.getServiceGroup();
        ifsaOccurrence = requestedService.getServiceOccurance();
        ifsaVersion = requestedService.getServiceVersion();
    } catch (JMSException e) {
        log.error(getLogPrefix() + "got error getting serviceparameter", e);
    }
    String BIFname = null;
    try {
        BIFname = message.getBifName();
        if (StringUtils.isNotEmpty(BIFname)) {
            threadContext.put(THREAD_CONTEXT_BIFNAME_KEY, BIFname);
        }
    } catch (JMSException e) {
        log.error(getLogPrefix() + "got error getting BIFname", e);
    }
    byte[] btcData = null;
    try {
        btcData = message.getBtcData();
    } catch (JMSException e) {
        log.error(getLogPrefix() + "got error getting btcData", e);
    }
    if (log.isDebugEnabled()) {
        log.debug(getLogPrefix() + "got message for [" + fullIfsaServiceName + "] with JMSDeliveryMode=[" + mode + "] \n  JMSMessageID=[" + id + "] \n  JMSCorrelationID=[" + cid + "] \n  BIFname=[" + BIFname + "] \n  ifsaServiceName=[" + ifsaServiceName + "] \n  ifsaGroup=[" + ifsaGroup + "] \n  ifsaOccurrence=[" + ifsaOccurrence + "] \n  ifsaVersion=[" + ifsaVersion + "] \n  Timestamp Sent=[" + DateUtils.format(tsSent) + "] \n  ReplyTo=[" + ((replyTo == null) ? "none" : replyTo.toString()) + "] \n  MessageHeaders=[" + displayHeaders(message) + "\n" + // + "] \n  btcData=["+ btcData
        "] \n  Message=[" + message.toString() + "\n]");
    }
    // if (cid == null) {
    // if (StringUtils.isNotEmpty(BIFname)) {
    // cid = BIFname;
    // if (log.isDebugEnabled()) log.debug("Setting correlation ID to BIFname ["+cid+"]");
    // } else {
    // cid = id;
    // if (log.isDebugEnabled()) log.debug("Setting correlation ID to MessageId ["+cid+"]");
    // }
    // }
    PipeLineSessionBase.setListenerParameters(threadContext, id, BIFname, null, tsSent);
    threadContext.put("timestamp", tsSent);
    threadContext.put("replyTo", ((replyTo == null) ? "none" : replyTo.toString()));
    threadContext.put("messageText", messageText);
    threadContext.put("fullIfsaServiceName", fullIfsaServiceName);
    threadContext.put("ifsaServiceName", ifsaServiceName);
    threadContext.put("ifsaGroup", ifsaGroup);
    threadContext.put("ifsaOccurrence", ifsaOccurrence);
    threadContext.put("ifsaVersion", ifsaVersion);
    threadContext.put("ifsaBifName", BIFname);
    threadContext.put("ifsaBtcData", btcData);
    Map udz = (Map) message.getIncomingUDZObject();
    if (udz != null) {
        String contextDump = "ifsaUDZ:";
        for (Iterator it = udz.keySet().iterator(); it.hasNext(); ) {
            String key = (String) it.next();
            String value = (String) udz.get(key);
            contextDump = contextDump + "\n " + key + "=[" + value + "]";
            threadContext.put(key, value);
        }
        if (log.isDebugEnabled()) {
            log.debug(getLogPrefix() + contextDump);
        }
    }
    return BIFname;
}
Also used : Destination(javax.jms.Destination) JMSException(javax.jms.JMSException) Date(java.util.Date) IMessageWrapper(nl.nn.adapterframework.core.IMessageWrapper) IFSAMessage(com.ing.ifsa.IFSAMessage) IFSAServiceName(com.ing.ifsa.IFSAServiceName) Iterator(java.util.Iterator) Map(java.util.Map)

Example 4 with IFSAServiceName

use of com.ing.ifsa.IFSAServiceName in project iaf by ibissource.

the class PushingIfsaProviderListener method open.

public void open() throws ListenerException {
    try {
        openService();
        IFSAServicesProvided services = getServiceQueue().getIFSAServicesProvided();
        for (int i = 0; i < services.getNumberOfServices(); i++) {
            IFSAServiceName service = services.getService(i);
            String protocol = (service.IsFireAndForgetService() ? "Fire and Forget" : "Request/Reply");
            log.info(getLogPrefix() + "providing ServiceName [" + service.getServiceName() + "] ServiceGroup [" + service.getServiceGroup() + "] protocol [" + protocol + "] ServiceVersion [" + service.getServiceVersion() + "]");
        }
        jmsConnector.start();
    } catch (Exception e) {
        throw new ListenerException(getLogPrefix(), e);
    }
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) IFSAServiceName(com.ing.ifsa.IFSAServiceName) IfsaException(nl.nn.adapterframework.extensions.ifsa.IfsaException) ListenerException(nl.nn.adapterframework.core.ListenerException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) JMSException(javax.jms.JMSException) IFSAServicesProvided(com.ing.ifsa.IFSAServicesProvided)

Aggregations

IFSAServiceName (com.ing.ifsa.IFSAServiceName)4 JMSException (javax.jms.JMSException)4 IFSAMessage (com.ing.ifsa.IFSAMessage)2 IFSAServicesProvided (com.ing.ifsa.IFSAServicesProvided)2 Date (java.util.Date)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Destination (javax.jms.Destination)2 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)2 IMessageWrapper (nl.nn.adapterframework.core.IMessageWrapper)2 ListenerException (nl.nn.adapterframework.core.ListenerException)2 IfsaException (nl.nn.adapterframework.extensions.ifsa.IfsaException)2 HashMap (java.util.HashMap)1