Package org.torquebox.messaging

Examples of org.torquebox.messaging.MessageProcessorMetaData


            QueueMetaData queue = new QueueMetaData();
            queue.setName( queueName );
            queue.setDurable( task.isDurable() );
            unit.addToAttachmentList( QueueMetaData.ATTACHMENTS_KEY, queue );

            MessageProcessorMetaData processorMetaData = new MessageProcessorMetaData();
            processorMetaData.setDestinationName( queueName );
            processorMetaData.setRubyClassName( task.getRubyClassName(), task.getLocation() );
            processorMetaData.setConcurrency( task.getConcurrency() );
            processorMetaData.setMessageSelector( "JMSCorrelationID IS NULL" );
            processorMetaData.setXAEnabled( task.isXAEnabled() );
            unit.addToAttachmentList( MessageProcessorMetaData.ATTACHMENTS_KEY, processorMetaData );
        }
    }
View Full Code Here


        @SuppressWarnings({ "rawtypes", "unchecked" })
        public static MessageProcessorMetaData subscribe(String handler, String destination, Map options) {
            if (options == null)
                options = Collections.EMPTY_MAP;
            MessageProcessorMetaData result = new MessageProcessorMetaData();
            result.setDurable( (Boolean) options.get( "durable" ) );
            result.setSynchronous((Boolean) options.get("synchronous"));
            result.setClientID((String) options.get("client_id"));
            result.setDestinationName(destination);
            result.setMessageSelector((String) options.get("selector"));

            // In case this is a synchronous message processor
            // we do not want to receive own replies
            if (result.isSynchronous()) {
                if (result.getMessageSelector() == null) {
                    // Message selector was not provided
                    result.setMessageSelector( "JMSCorrelationID IS NULL" );
                } else {
                    // Message selector was provided, we need to use it
                    result.setMessageSelector( "(JMSCorrelationID IS NULL) AND (" + result.getMessageSelector() + ")" );
                }
            }

            if (options.containsKey("singleton")) {
                result.setSingleton( (Boolean) options.get( "singleton" ) );
            }
            if (options.containsKey("stopped")) {
                result.setStopped( (Boolean) options.get( "stopped" ) );
            }
            if (options.containsKey( "xa" )) {
                result.setXAEnabled( (Boolean ) options.get( "xa" ) );
            }
            result.setRubyClassName( StringUtils.camelize( handler ) );
            result.setRubyRequirePath( StringUtils.underscore( handler ) );
            result.setRubyConfig( (Map) options.get( "config" ) );
            result.setConcurrency( (Integer) options.get( "concurrency" ) );

            return result;
        }
View Full Code Here

        assertEquals( "marshal", env.get( "DEFAULT_MESSAGE_ENCODING" ) );

        List<MessageProcessorMetaData> procMetaData = unit.getAttachmentList( MessageProcessorMetaData.ATTACHMENTS_KEY );
        assertEquals( 1, procMetaData.size() );
        MessageProcessorMetaData metaData = procMetaData.iterator().next();
        assertNotNull( metaData );
        assertEquals( "MyClass", metaData.getRubyClassName() );
        assertEquals( "/topics/foo", metaData.getDestinationName() );
    }
View Full Code Here

    @Test
    public void testSingleMessagingConfig() throws Exception {
        List<MessageProcessorMetaData> allMetaData = getMetaData( "single-messaging.yml" );
        assertEquals( 1, allMetaData.size() );

        MessageProcessorMetaData metaData = allMetaData.iterator().next();
        assertNotNull( metaData );
        assertEquals( "MyClass", metaData.getRubyClassName() );
        assertEquals( "/topics/foo", metaData.getDestinationName() );
        assertEquals( "mySelector", metaData.getMessageSelector() );
        assertEquals( "toast", metaData.getRubyConfig().get( "a" ) );
        assertEquals( new Integer( 2 ), metaData.getConcurrency() );
        assertFalse( metaData.isStopped() );
    }
View Full Code Here

    }

    @Test
    public void testConfigOptionsForArray() throws Exception {
        List<MessageProcessorMetaData> allMetaData = getMetaData( "messaging.yml" );
        MessageProcessorMetaData metadata = find( allMetaData, "/array", "Two" );
        assertEquals( "x > 18", metadata.getMessageSelector() );
        assertFalse( metadata.isXAEnabled() );
        Map<String, Object> config = metadata.getRubyConfig();
        assertEquals( "ex", config.get( "x" ) );
        assertEquals( "why", config.get( "y" ) );
        assertTrue( isUnconfigured( find( allMetaData, "/array", "One" ) ) );
        assertTrue( isUnconfigured( find( allMetaData, "/array", "Three" ) ) );
    }
View Full Code Here

    }

    @Test
    public void testConfigOptionsForHash() throws Exception {
        List<MessageProcessorMetaData> allMetaData = getMetaData( "messaging.yml" );
        MessageProcessorMetaData metadata = find( allMetaData, "/hash", "B" );
        assertEquals( "y < 18", metadata.getMessageSelector() );
        assertTrue( metadata.isXAEnabled() );
        Map<String, Object> config = metadata.getRubyConfig();
        assertEquals( "ache", config.get( "h" ) );
        assertEquals( "eye", config.get( "i" ) );
        assertEquals( new Integer( 3 ), metadata.getConcurrency() );
        assertTrue( isUnconfigured( find( allMetaData, "/hash", "A" ) ) );
    }
View Full Code Here

    }

    @Test
    public void testMergedMap() throws Exception {
        List<MessageProcessorMetaData> allMetaData = getMetaData( "messaging.yml" );
        MessageProcessorMetaData metadata = find( allMetaData, "/hash", "Two" );
        assertEquals( "x > 18", metadata.getMessageSelector() );
        assertFalse( metadata.isXAEnabled() );
        Map<String, Object> config = metadata.getRubyConfig();
        assertEquals( "ex", config.get( "x" ) );
        assertEquals( "why", config.get( "y" ) );
    }
View Full Code Here

    }

    @Test
    public void testDefaultConcurrency() throws Exception {
        List<MessageProcessorMetaData> allMetaData = getMetaData( "messaging.yml" );
        MessageProcessorMetaData metadata = find( allMetaData, "/hash", "A" );
        assertEquals( new Integer( 1 ), metadata.getConcurrency() );
    }
View Full Code Here

    }

    @Test
    public void testStopped() throws Exception {
        List<MessageProcessorMetaData> allMetaData = getMetaData( "messaging-stopped.yml" );
        MessageProcessorMetaData metadata = find( allMetaData, "/topics/foo", "MyClass" );
        assertTrue( metadata.isStopped() );
    }
View Full Code Here

    @Test
    public void testPoolRequired() throws Exception {
        DeploymentPhaseContext phaseContext = createPhaseContext();
        DeploymentUnit unit = phaseContext.getDeploymentUnit();

        unit.addToAttachmentList( MessageProcessorMetaData.ATTACHMENTS_KEY, new MessageProcessorMetaData() );

        deploy( phaseContext );

        List<PoolMetaData> allPools = unit.getAttachmentList( PoolMetaData.ATTACHMENTS_KEY );
        assertEquals( 1, allPools.size() );
View Full Code Here

TOP

Related Classes of org.torquebox.messaging.MessageProcessorMetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.