Package org.drools.grid.io

Examples of org.drools.grid.io.Conversation



        ConversationManager cm = new ConversationManagerImpl( new GridImpl("peer"),
                                                              l );

        Conversation cv = cm.startConversation( "s1",
                                                new InetSocketAddress( "127.0.0.1",
                                                                       8000 ),
                                                                       "r1" );

        BlockingMessageResponseHandler blockHandler = new BlockingMessageResponseHandler();

        cv.sendMessage( "hello",
                        blockHandler );

        Message msg = blockHandler.getMessage(100, 5000 );
        System.out.println( msg.getBody() );

        cv.endConversation();
        if ( acc.isOpen() ) {
            acc.close();
        }
        assertEquals( false,
                      acc.isOpen() );
View Full Code Here


            sockets[0] = (InetSocketAddress) addr;
        }

        BlockingMessageResponseHandler handler = new BlockingMessageResponseHandler();
        Exception exception = null;
        Conversation conv = null;
        for ( InetSocketAddress socket : sockets ) {
            try {
                conv = conversationManager.startConversation( senderId,
                                                              socket,
                                                              id );
                conv.sendMessage( body,
                                  handler );
                exception = null;
            } catch ( Exception e ) {
                exception = e;
                if ( conv != null ) {
                    conv.endConversation();
                }
            }
            if ( exception == null ) {
                break;
            }
        }
        if ( exception != null ) {
            throw new RuntimeException( "Unable to send message",
                                        exception );
        }
        try {
            return handler.getMessage().getBody();
        } finally {
            conv.endConversation();
        }
    }
View Full Code Here

            sockets[0] = (InetSocketAddress) addr;
        }

        BlockingMessageResponseHandler handler = new BlockingMessageResponseHandler();
        Exception exception = null;
        Conversation conv = null;
        for ( InetSocketAddress socket : sockets ) {
            try {
                conv = conversationManager.startConversation( senderId,
                                                              socket,
                                                              id );
                conv.sendMessage( body,
                                  handler );
                exception = null;
            } catch ( Exception e ) {
                exception = e;
                if ( conv != null ) {
                    conv.endConversation();
                }
            }
            if ( exception == null ) {
                break;
            }
        }
        if ( exception != null ) {
            throw new RuntimeException( "Unable to send message",
                                        exception );
        }
        try {
            return handler.getMessage().getBody();
        } finally {
            conv.endConversation();
        }
    }
View Full Code Here

            sockets[0] = (InetSocketAddress) addr;
        }

        AsyncMessageResponseHandler handler = new AsyncMessageResponseHandler();
        Exception exception = null;
        Conversation conv = null;
        for ( InetSocketAddress socket : sockets ) {
            try {
                conv = conversationManager.startConversation( senderId,
                                                              socket,
                                                              id );
                conv.sendMessage( body,
                                  handler );
                exception = null;
            } catch ( Exception e ) {
                exception = e;
                if ( conv != null ) {
                    conv.endConversation();
                }
            }
            if ( exception == null ) {
                break;
            }
        }
        if ( exception != null ) {
            throw new RuntimeException( "Unable to send message",
                                        exception );
        }
        //try {
        //    return handler.getMessage().getBody();
        //}
        //finally {
            conv.endConversation();
        //}
    }
View Full Code Here

            sockets[0] = (InetSocketAddress) addr;
        }

        BlockingMessageResponseHandler handler = new BlockingMessageResponseHandler();
        Exception exception = null;
        Conversation conv = null;
        for ( InetSocketAddress socket : sockets ) {
            try {
                conv = conversationManager.startConversation( "", // TODO add ID later
                                                              socket,
                                                              id );
                conv.sendMessage( body,
                                  handler );
                exception = null;
            } catch ( Exception e ) {
                exception = e;
                conv.endConversation();
            }
            if ( exception == null ) {
                break;
            }
        }
        if ( exception != null ) {
            throw new RuntimeException( "Unable to send message",
                                        exception );
        }
        try {
            return handler.getMessage().getBody();
        } finally {
            conv.endConversation();
        }
    }
View Full Code Here

            sockets = new InetSocketAddress[1];
            sockets[0] = (InetSocketAddress) addr;
        }
        BlockingMessageResponseHandler handler = new BlockingMessageResponseHandler();
        Exception exception = null;
        Conversation conv = null;
        for ( InetSocketAddress socket : sockets ) {
            try {
                conv = conversationManager.startConversation( "",
                                                              socket,
                                                              id );
                conv.sendMessage( body,
                                  handler );
                exception = null;
            } catch ( Exception e ) {
                exception = e;
                if ( conv != null ) {
                    conv.endConversation();
                }
            }
            if ( exception == null ) {
                break;
            }
        }
        if ( exception != null ) {
            throw new RuntimeException( "Unable to send message",
                                        exception );
        }
        try {
            return handler.getMessage().getBody();
        } finally {
            conv.endConversation();
        }
    }
View Full Code Here

    @Override
    public void messageReceived(IoSession session,
                                Object object) throws Exception {
        Message msg = (Message) object;
        Conversation conversation = new ConversationImpl( null, //TODO this should not be null, but we currently have no concept of a ConversationManager on the Acceptor
                                                          msg.getConversationId(),
                                                          this.senderId,
                                                          msg.getSenderId(),
                                                          this.dispathListener,
                                                          msg,
                                                          new MinaIoWriter( session ),
                                                          null );
        this.messageHandler.messageReceived( conversation,
                                             msg );

        conversation.endConversation();

        disposeSession( session );
    }
View Full Code Here

            sockets = new InetSocketAddress[1];
            sockets[0] = (InetSocketAddress) addr;
        }
        BlockingMessageResponseHandler handler = new BlockingMessageResponseHandler();
        Exception exception = null;
        Conversation conv = null;
        for ( InetSocketAddress socket : sockets ) {
            try {
                conv = conversationManager.startConversation( "",
                                                              socket,
                                                              id );
                conv.sendMessage( body,
                                  handler );
                exception = null;
            } catch ( Exception e ) {
                exception = e;
                if ( conv != null ) {
                    conv.endConversation();
                }
            }
            if ( exception == null ) {
                break;
            }
        }
        if ( exception != null ) {
            throw new RuntimeException( "Unable to send message",
                                        exception );
        }
        try {
            return handler.getMessage().getBody();
        } catch (Throwable t){
            throw new RuntimeException(t);
        } finally {
            conv.endConversation();
        }
    }
View Full Code Here


        ConversationManager cm = new ConversationManagerImpl( new GridImpl(),
                                                              l );

        Conversation cv = cm.startConversation( "s1",
                                                new InetSocketAddress( "127.0.0.1",
                                                                       5012 ),
                                                                       "r1" );

        BlockingMessageResponseHandler blockHandler = new BlockingMessageResponseHandler();

        cv.sendMessage( "hello",
                        blockHandler );

        Message msg = blockHandler.getMessage( 5000 );
        System.out.println( msg.getBody() );

        cv.endConversation();
        if ( acc.isOpen() ) {
            acc.close();
        }
        assertEquals( false,
                      acc.isOpen() );
View Full Code Here


        ConversationManager cm = new ConversationManagerImpl( new GridImpl("peer"),
                                                              l );

        Conversation cv = cm.startConversation( "s1",
                                                new InetSocketAddress( "127.0.0.1",
                                                                       8000 ),
                                                                       "r1" );

        BlockingMessageResponseHandler blockHandler = new BlockingMessageResponseHandler();

        cv.sendMessage( "hello",
                        blockHandler );

        Message msg = blockHandler.getMessage( 5000 );
        System.out.println( msg.getBody() );

        cv.endConversation();
        if ( acc.isOpen() ) {
            acc.close();
        }
        assertEquals( false,
                      acc.isOpen() );
View Full Code Here

TOP

Related Classes of org.drools.grid.io.Conversation

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.