uima-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manuel Fiorelli <manuel.fiore...@gmail.com>
Subject Re: How to have client, service and broker co-located using UIMA-AS
Date Wed, 04 Oct 2017 20:23:30 GMT
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" <cwiklik@apache.org> 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 <cwiklik@apache.org>
> 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<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 <
> > manuel.fiorelli@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:
> >>
> >> <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.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
> >> org.apache.uima.aae.handler.input.ProcessResponseHandler.han
> >> dle(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.o
> >> nMessage(UimaVmMessageListener.java:107)
> >>     at
> >> org.apache.uima.aae.spi.transport.vm.UimaVmMessageDispatcher
> >> $1.run(UimaVmMessageDispatcher.java:70)
> >>     at
> >> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
> >> Executor.java:1142)
> >>     at
> >> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
> >> lExecutor.java:617)
> >>     at
> >> org.apache.uima.aae.UimaAsThreadFactory$1.run(UimaAsThreadFa
> >> ctory.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
> >>
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message