Search in sources :

Example 1 with JmsService

use of org.apache.ofbiz.service.config.model.JmsService in project ofbiz-framework by apache.

the class JmsServiceEngine method run.

protected Map<String, Object> run(ModelService modelService, Map<String, Object> context) throws GenericServiceException {
    JmsService serviceElement = getServiceElement(modelService);
    List<Server> serverList = serviceElement.getServers();
    Map<String, Object> result = new HashMap<String, Object>();
    for (Server server : serverList) {
        String serverType = server.getType();
        if ("topic".equals(serverType))
            result.putAll(runTopic(modelService, context, server));
        else if ("queue".equals(serverType))
            result.putAll(runQueue(modelService, context, server));
        else
            throw new GenericServiceException("Illegal server messaging type.");
    }
    return result;
}
Also used : JmsService(org.apache.ofbiz.service.config.model.JmsService) Server(org.apache.ofbiz.service.config.model.Server) HashMap(java.util.HashMap) GenericServiceException(org.apache.ofbiz.service.GenericServiceException)

Example 2 with JmsService

use of org.apache.ofbiz.service.config.model.JmsService in project ofbiz-framework by apache.

the class JmsListenerFactory method loadListeners.

// Load the JMS listeners
private void loadListeners() {
    try {
        List<JmsService> jmsServices = ServiceConfigUtil.getServiceEngine().getJmsServices();
        if (Debug.verboseOn())
            Debug.logVerbose("Loading JMS Listeners.", module);
        for (JmsService service : jmsServices) {
            StringBuilder serverKey = new StringBuilder();
            for (Server server : service.getServers()) {
                try {
                    if (server.getListen()) {
                        // create a server key
                        serverKey.append(server.getJndiServerName() + ":");
                        serverKey.append(server.getJndiName() + ":");
                        serverKey.append(server.getTopicQueue());
                        // store the server element
                        servers.put(serverKey.toString(), server);
                        // load the listener
                        GenericMessageListener listener = loadListener(serverKey.toString(), server);
                        // store the listener w/ the key
                        if (serverKey.length() > 0 && listener != null)
                            listeners.put(serverKey.toString(), listener);
                    }
                } catch (GenericServiceException gse) {
                    Debug.logInfo("Cannot load message listener " + serverKey + " error: (" + gse.toString() + ").", module);
                } catch (Exception e) {
                    Debug.logError(e, "Uncaught exception.", module);
                }
            }
        }
    } catch (GenericConfigException e) {
        Debug.logError(e, "Exception thrown while loading JMS listeners: ", module);
    }
}
Also used : GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) JmsService(org.apache.ofbiz.service.config.model.JmsService) Server(org.apache.ofbiz.service.config.model.Server) GenericServiceException(org.apache.ofbiz.service.GenericServiceException) GenericConfigException(org.apache.ofbiz.base.config.GenericConfigException) GenericServiceException(org.apache.ofbiz.service.GenericServiceException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

GenericServiceException (org.apache.ofbiz.service.GenericServiceException)2 JmsService (org.apache.ofbiz.service.config.model.JmsService)2 Server (org.apache.ofbiz.service.config.model.Server)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 GenericConfigException (org.apache.ofbiz.base.config.GenericConfigException)1