Re: How to have client, service and broker co-located using UIMA-AS

2017-10-04 Thread Manuel Fiorelli
Hi Jaroslaw

Thank you for your answer. Tomorrow, I will apply your suggestions and tell
you what happens.

Il 4 ott 2017 19:50, "Jaroslaw Cwiklik"  ha scritto:

> Manuel, small correction. Towards the end replace this
>
> client.sendCAS(cas);
>
> with
>
> client.sendAndReceiveCAS(cas);
>
> Simpler, synchronous msg exchange between client and a service.
>
> Jerry Cwiklik
>
> On Wed, Oct 4, 2017 at 1:00 PM, Jaroslaw Cwiklik 
> wrote:
>
> > 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 appCtx = new HashMap();
> > appCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath,
> >$UIMA_HOME+"/bin/dd2spring.xsl");
> > appCtx.put(UimaAsynchronousEngine.SaxonClasspath,
> >"file:"+$UIMA_HOME+"/saxon/saxon8.jar");
> >
> > String aDeploymentDescriptorPath =
> >   
> >
> > // deploy in-process service
> > String serviceId =
> >   client.deploy(aDeploymentDescriptorPath, appCtx);
> >
> > String endpoint = ; // 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 <
> > manuel.fiore...@gmail.com> 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:
> >>
> >> 
> >> 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.
> >> 
> >>
> >> 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:
> >>
> >> 
> >> 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.AggregateAnalysisEngineContro
> >> ller_impl.sendVMMessage(AggregateAnalysisEngineControl
> ler_impl.java:2393)
> >> at
> >> org.apache.uima.aae.controller.AggregateAnalysisEngineContro
> >> ller_impl.sendReplyToCollocatedClient(AggregateAnalysisEngin
> >> eController_impl.java:2287)
> >> at
> >> org.apache.uima.aae.controller.AggregateAnalysisEngineContro
> >> ller_impl.replyToClient(AggregateAnalysisEngineControl
> ler_impl.java:2344)
> >> at
> >> org.apache.uima.aae.controller.AggregateAnalysisEngineContro
> >> ller_impl.finalStep(AggregateAnalysisEngineController_impl.java:1862)
> >> at
> >> org.apache.uima.aae.controller.AggregateAnalysisEngineContro
> >> ller_impl.executeFlowStep(AggregateAnalysisEngineController_
> >> impl.java:2489)
> >> at
> >> org.apache.uima.aae.controller.AggregateAnalysisEngineContro
> >> ller_impl.process(AggregateAnalysisEngineController_impl.java:1271)
> >> at
> >> org.apache.uima.aae.handler.HandlerBase.invokeProcess(Handle
> >> rBase.java:118)
> >> at
> >> org.apache.uima.aae.handler.input.ProcessResponseHandler.can
> >> celTimerAndProcess(ProcessResponseHandler.java:117)
> >> at
> >> org.apache.uima.aae.handler.input.ProcessResponseHandler.han
> >> dleProcessResponseWithCASReference(ProcessResponseHandler.java:485)
> >> at
> >> 

Re: How to have client, service and broker co-located using UIMA-AS

2017-10-04 Thread Jaroslaw Cwiklik
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 appCtx = new HashMap();
appCtx.put(UimaAsynchronousEngine.DD2SpringXsltFilePath,
   $UIMA_HOME+"/bin/dd2spring.xsl");
appCtx.put(UimaAsynchronousEngine.SaxonClasspath,
   "file:"+$UIMA_HOME+"/saxon/saxon8.jar");

String aDeploymentDescriptorPath =
  

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

String endpoint = ; // 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 
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:
>
> 
> 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.
> 
>
> 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:
>
> 
> 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)
> 
>
> The exception above does not happen when I use a remote broker, so I
> suspect 

How to have client, service and broker co-located using UIMA-AS

2017-10-04 Thread Manuel Fiorelli
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:


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.


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:


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.AggregateAnalysisEngineController_impl.sendVMMessage(AggregateAnalysisEngineController_impl.java:2393)
at
org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl.sendReplyToCollocatedClient(AggregateAnalysisEngineController_impl.java:2287)
at
org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl.replyToClient(AggregateAnalysisEngineController_impl.java:2344)
at
org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl.finalStep(AggregateAnalysisEngineController_impl.java:1862)
at
org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl.executeFlowStep(AggregateAnalysisEngineController_impl.java:2489)
at
org.apache.uima.aae.controller.AggregateAnalysisEngineController_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)


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