Hi Manuel, you *can* colocate broker, client and a service in the same
process. Here is the code to get this done. Sorry did not test this. You
need to create a deployment descriptor (xml file) to be able to deploy a
service.

// Deploy in-process broker
String uri = "tcp://"localhost:61616";
BrokerService broker =
     BrokerFactory.createBroker(new
URI("broker:()/localhost?persistent=false"));
TransportConnector tcpConnector = broker.addConnector(uri);
broker.start();
//------------------

UimaAsynchronousEngine client =
new BaseUIMAAsynchronousEngine_impl();

Map<String,String> appCtx = new HashMap();
appCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath,
           $UIMA_HOME+"/bin/dd2spring.xsl");
appCtx.put(UimaAsynchronousEngine.SaxonClasspath,
           "file:"+$UIMA_HOME+"/saxon/saxon8.jar");

String aDeploymentDescriptorPath =
  <path to dd.xml>

// deploy in-process service
String serviceId =
  client.deploy(aDeploymentDescriptorPath, appCtx);

String endpoint = <queue name>; // from the deployment descriptor

appCtx.put(UimaAsynchronousEngine.ServerUri, uri);
appCtx.put(UimaAsynchronousEngine.ENDPOINT, endpoint);

// connect client with an in-process service
client.initialize(appCtx);

CAS cas = client.getCAS();
cas.setDocumentText("Some Text");
client.sendCAS(cas);

client.stop();



On Wed, Oct 4, 2017 at 11:37 AM, Manuel Fiorelli <[email protected]>
wrote:

> Hi everybody
>
> Within the documentation of UIMA-AS, specifically within the section
> Terminology (
> https://uima.apache.org/d/uima-as-2.9.0/uima_async_
> scaleout.html#ugr.async.ov.terminology),
> the description of Queue Broker says:
>
> <cite>
> Queue brokers manage one or more named queues. The brokers are identified
> using a URL, representing where they are on the network. When the queue
> broker is co-located with the AS client and service, CASes are passed by
> reference, avoiding serialization / deserialization.
> </cite>
>
> Unfortunately, I could not find in the documentation how to place broker,
> client and service in the same JVM (co-location).
>
> After some web searches, experiments and exploration of the source code of
> UIMA-AS, I found that the solution may require the use of the URL
> "vm://localhost?broker.persistent=false" for the broker.
>
> In my sample program, I deploy a service (an asynchronous aggregate AE) and
> then create an asynchronous client using the URL above, but then I receive
> the following NullPointerException:
>
> <cite>
> ott 04, 2017 5:29:28 PM
> org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl
> replyToClient
> AVVERTENZA: Service: Top Level Aggregate Service Runtime Exception
> ott 04, 2017 5:29:28 PM
> org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl
> replyToClient
> AVVERTENZA:
> java.lang.NullPointerException
>     at
> org.apache.uima.aae.controller.AggregateAnalysisEngineControl
> ler_impl.sendVMMessage(AggregateAnalysisEngineController_impl.java:2393)
>     at
> org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl.
> sendReplyToCollocatedClient(AggregateAnalysisEngineControl
> ler_impl.java:2287)
>     at
> org.apache.uima.aae.controller.AggregateAnalysisEngineControl
> ler_impl.replyToClient(AggregateAnalysisEngineController_impl.java:2344)
>     at
> org.apache.uima.aae.controller.AggregateAnalysisEngineControl
> ler_impl.finalStep(AggregateAnalysisEngineController_impl.java:1862)
>     at
> org.apache.uima.aae.controller.AggregateAnalysisEngineControl
> ler_impl.executeFlowStep(AggregateAnalysisEngineController_impl.java:2489)
>     at
> org.apache.uima.aae.controller.AggregateAnalysisEngineControl
> ler_impl.process(AggregateAnalysisEngineController_impl.java:1271)
>     at
> org.apache.uima.aae.handler.HandlerBase.invokeProcess(
> HandlerBase.java:118)
>     at
> org.apache.uima.aae.handler.input.ProcessResponseHandler.
> cancelTimerAndProcess(ProcessResponseHandler.java:117)
>     at
> org.apache.uima.aae.handler.input.ProcessResponseHandler.
> handleProcessResponseWithCASReference(ProcessResponseHandler.java:485)
>     at
> org.apache.uima.aae.handler.input.ProcessResponseHandler.
> handle(ProcessResponseHandler.java:767)
>     at
> org.apache.uima.aae.handler.HandlerBase.delegate(HandlerBase.java:149)
>     at
> org.apache.uima.aae.handler.input.ProcessRequestHandler_impl.handle(
> ProcessRequestHandler_impl.java:1113)
>     at
> org.apache.uima.aae.spi.transport.vm.UimaVmMessageListener.onMessage(
> UimaVmMessageListener.java:107)
>     at
> org.apache.uima.aae.spi.transport.vm.UimaVmMessageDispatcher$1.run(
> UimaVmMessageDispatcher.java:70)
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
>     at
> org.apache.uima.aae.UimaAsThreadFactory$1.run(
> UimaAsThreadFactory.java:132)
>     at java.lang.Thread.run(Thread.java:745)
> </cite>
>
> The exception above does not happen when I use a remote broker, so I
> suspect that I am doing something wrong with my attempt to place all parts
> in the same JVM.
>
> Does anyone knows how to achieve my goal?
>
> Thanks in advance,
> Manuel Fiorelli
>

Reply via email to