JBoss Community

Use of ServiceInvoker to test an ESB service

created by Brian Fitzpatrick in JBoss ESB Development - View the full discussion

Hi all...

 

I'm trying to customize some test code to test the aggregator sample via a SendEsbMessage java class, similar to how it's been used for other ESB runtime examples, and am not having much luck.

 

To give some context, I'm trying to make some of the examples that aren't currently usable in JBoss Tools into importable examples that folks can import, build, deploy, and test within the tooling.

 

Here's what I have so far:

 

{code}

public class SendEsbMessage

{

    public static void main(String args[]) throws Exception

    {

//      Setting the ConnectionFactory such that it will use scout

        System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");

       

        Message esbMessage = MessageFactory.getInstance().getMessage();

 

        if (args.length < 3)

        {

            String fileContent = readFile ("SampleOrder.xml");

            System.out.println("---------------------------------------------");

            System.out.println(fileContent);

            System.out.println("---------------------------------------------");

            System.out.println("Usage SendEsbMessage <category> <name> <text to send>");

            args = new String[]{"Aggregation", "OrderAggregrator", fileContent};

        }

       

        esbMessage.getBody().add(args[2]);

        new ServiceInvoker(args[0], args[1]).deliverAsync(esbMessage);

       

    }

   

    private static String readFile( String file ) throws IOException {

        BufferedReader reader = new BufferedReader( new FileReader (file));

        String line  = null;

        StringBuilder stringBuilder = new StringBuilder();

        String ls = System.getProperty("line.separator");

        while( ( line = reader.readLine() ) != null ) {

            stringBuilder.append( line );

            stringBuilder.append( ls );

        }

        return stringBuilder.toString();

     }

   

}

{code}

 

Am I doing something obviously wrong? There's a queue associated with the OrderAggregator service, and it appears that's what I need to put the sample on...

 

Thanks in advance!

--Fitz

Reply to this message by going to Community

Start a new discussion in JBoss ESB Development at Community