ode-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cory <cory.har...@gmail.com>
Subject Re: Commented code in StartCatchAction
Date Tue, 15 Aug 2006 21:16:35 GMT
Looks like the DocumentFormattableValue works for you.

SPIAdapterInteractionFactory.createcreateDocumentInteraction() could
probably be used in place of XMLInteractionObject and
DocumentFormattableValue.

The interaction stuff in the BPE has grown over the projects life time
and needs to be cleaned up.  The cleaned up version is what I proposed
as the content API for Ode(checked into the scratch area right now).

The integration layer has the oportunity to implement an interaction.
In this case SM could implement a NomalizedMessageInteraction that
holds a NormalizedMessage.  Right now it looks like the NM Source is
always converted into a DOM on the way in and back into a Source when
it comes out. You could possibly get more performance if that was
deferred until it needs to happen.  Take for example the fault case.
If a NormalizedMessageInteraction was used and the BPEL catches the
fault and assigns it to a part for return or to invoke another
service, no conversions would take place because the bus would be
getting back a NormalizedMessage.

We have had success with a few  Interaction implementations that wrap
proprietary data objects.

-cory

On 8/14/06, Grant McDonald <gmcdonald@infocomp.com> wrote:
> Cory,
>
> I tried using a DescribedValue object for the fault and response messages
> but this gets wrapped in a CannedFormattableObject which has some other
> issues when accessing it (UnsupportedOperation exception for wrapped
> Document instances - go figure). So I've settled on using a
> DocumentFormattableValue for fault and respone messages and it looks like it
> works. Do you know of any caveats to this approach? (Btw, the call to the
> event director at the start of the process still uses an
> XMLInteractionObject and I can't see a way around that since it must an
> instance of IInteraction as invoke is called in during message correlation)
>
> Grant
>
> -----Original Message-----
> From: cory [mailto:cory.harper@gmail.com]
> Sent: Wednesday, 9 August 2006 5:38 AM
> To: ode-dev@incubator.apache.org
> Subject: Re: Commented code in StartCatchAction
>
>
> Hi Grant,
>
> The XMLInteractionObject is stuff that we were going to deprecate,
> hence the FormattableValueAdaptor.  I haven't had a chance to look at
> the SM integration and trace it all the way through, but could you try
> using a DescribedValue object in the BPRuntimeException instead of the
> XMLInteractionObject.
>
> -cory
>
> On 8/8/06, Grant McDonald <gmcdonald@infocomp.com> wrote:
> > I just did some more investigation and what it ends up as is a
> > CannedFormattableValue.  Is this what would be expected from an externally
> > received fault message?
> >
> > -----Original Message-----
> > From: Grant McDonald
> > Sent: Wednesday, 9 August 2006 2:28 AM
> > To: 'ode-dev@incubator.apache.org'
> > Subject: RE: Commented code in StartCatchAction
> >
> >
> > I think it's a combination of things:
> >
> > 1) (In ServiceMix JbiInvokeAction) Initially the faulted external action
> is
> > transformed into a Document, which is then set on an XMLInteraction object
> > and the interaction is added to a BPRuntimeException object which is then
> > thrown (this is simplified: read the fault name/part is determined etc
> etc):
> >
> >                 if (me.getFault() != null) {
> >                     Document fault;
> >                     try {
> >                         fault = (Document)
> > transformer.toDOMNode(me.getFault());
> >                         me.setStatus(ExchangeStatus.DONE);
> >                     } catch (Exception e) {
> >                         me.setError(e);
> >                         throw new ActionSystemException(e);
> >                     } finally {
> >                         channel.send(me);
> >                     }
> >                     Element e = fault.getDocumentElement();
> >                     // Try to determine fault name
> >                     String faultName = e.getLocalName();
> >                     String partName = BPEComponent.PART_PAYLOAD;
> >                     QName elemName = new QName(e.getNamespaceURI(),
> > e.getLocalName());
> >                     if (wsdlOperation != null) {
> >                         for (Iterator itFault =
> > wsdlOperation.getFaults().values().iterator(); itFault.hasNext();) {
> >                             Fault f = (Fault) itFault.next();
> >                             Part p = (Part)
> > f.getMessage().getParts().values().iterator().next();
> >                             if (elemName.equals(p.getTypeName())) {
> >                                 faultName = f.getName();
> >                                 partName = p.getName();
> >                             }
> >                         }
> >                     }
> >                     BPRuntimeException bpre = new
> > BPRuntimeException(faultName, "");
> >                     bpre.setNameSpace(e.getNamespaceURI());
> >                     XMLInteractionObject interaction = new
> > XMLInteractionObject();
> >                     interaction.setDocument(fault);
> >                     bpre.addPartMessage(partName, interaction);
> >                     throw bpre;
> >                 } else {
> >                     try {
> >                         nm = me.getMessage("out");
> >                         if (nm != null) {
> >                             XMLInteractionObject result = new
> > XMLInteractionObject();
> >                             result.setDocument((Document)
> > transformer.toDOMNode(nm));
> >                             output.put(outputPartName, result);
> >                         }
> >                         me.setStatus(ExchangeStatus.DONE);
> >                     } catch (Exception e) {
> >                         me.setError(e);
> >                         throw new ActionSystemException(e);
> >                     } finally {
> >                         channel.send(me);
> >                     }
> >                 }
> >             } else if (me.getStatus() == ExchangeStatus.ERROR) {
> >                 // Extract error
> >                 Exception error = me.getError();
> >                 throw new BPRuntimeException("Unknown", error);
> >             }
> >
> > 2) Coming back out of BPE again we attempt to load the payload in the
> > following manner:
> >
> >     protected Source getSourceFromPayload(Object payload) {
> >         Source inputSource;
> >         if (payload instanceof IFormattableValue) {
> >             IFormattableValue value = (IFormattableValue) payload;
> >             if (value.supportsGetValueAs(Document.class)) {
> >                 Document doc = (Document)
> value.getValueAs(Document.class);
> >                 inputSource = new DOMSource(doc);
> >             } else if (value.supportsGetValueAs(byte[].class)) {
> >                 byte[] data = (byte[]) value.getValueAs(byte[].class);
> >                 inputSource = new BytesSource(data);
> >             } else if (value.supportsGetValueAs(String.class)) {
> >                 String data = (String) value.getValueAs(String.class);
> >                 inputSource = new StringSource(data);
> >             } else {
> >                 throw new UnsupportedOperationException("Unable to
> retrieve
> > value");
> >             }
> >         } else if (payload instanceof Document) {
> >             inputSource = new DOMSource((Document) payload);
> >         } else if (payload instanceof byte[]) {
> >             inputSource = new BytesSource((byte[]) payload);
> >         } else if (payload instanceof String) {
> >             inputSource = new StringSource((String) payload);
> >         } else {
> >             throw new UnsupportedOperationException("Unable to retrieve
> > value");
> >         }
> >         return inputSource;
> >     }
> >
> > In this case the payload (which is the payload of the faultHandlers
> > variable) implements IFormattableValue and in actual fact is an instance
> > FormattableValueAdapter (I added logging to check this). What's strange is
> > that although the value is initially created as a Document object it
> doesn't
> > return true to the supportedGetValueAs method. The only way I could fudge
> it
> > was for the else case was to use the value.toString() to generate a string
> > response out of the object (which was in actual fact an xml message).
> >
> > I don't know if any of this sheds some light on the situation or not. Can
> > you tell me how these Interaction objects fit into the picture?
> >
> > -Grant
> >
> >
> >
> > -----Original Message-----
> > From: cory [mailto:cory.harper@gmail.com]
> > Sent: Wednesday, 9 August 2006 2:11 AM
> > To: ode-dev@incubator.apache.org
> > Subject: Re: Commented code in StartCatchAction
> >
> >
> > It's a bug that the catch by fault type was never fully implemented.
> > I think the commented out code in the StartCatchAction is a remnant
> > from an attempt to implement the catch by fault type.  Do you think
> > the exception your are seeing is related to the catch by fault type
> > bug?  Is your invoke in the fault handler trying to access a variable
> > that is not initialized or out of scope?
> >
> > -cory
> >
> > On 8/8/06, Grant McDonald <gmcdonald@infocomp.com> wrote:
> > > Hi,
> > >
> > > My colleagues and I have been using the BPE subproject from Apache ODE
> > > integrated with ServiceMix for some time now.  During the development of
> > our
> > > BPEL flows it became obvious that the contents of fault messages is not
> > > properly available to faultHandlers and results in the following
> > stacktrace:
> > >
> > > java.lang.UnsupportedOperationException: Unable to retrieve value
> > >         at
> > >
> >
> org.apache.servicemix.bpe.external.JbiInvokeAction.getSourceFromPayload(JbiI
> > > nvokeAction.java:276)
> > >         at
> > >
> >
> org.apache.servicemix.bpe.external.JbiInvokeAction.execute(JbiInvokeAction.j
> > > ava:179)
> > >         at
> > >
> >
> org.apache.ode.bpe.action.bpel.ExternalServiceAction.execute(ExternalService
> > > Action.java:230)
> > >         at
> > >
> >
> org.apache.servicemix.bpe.external.JbiExternalAction.execute(JbiExternalActi
> > > on.java:129)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.executeActions(ProcessInstance.jav
> > > a:359)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.evaluate(ProcessInstance.java:325)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.evaluate(ProcessInstance.java:414)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.processInternalEvent(ProcessInstan
> > > ce.java:254)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.processEvent(ProcessInstance.java:
> > > 209)
> > >         at
> > >
> >
> org.apache.ode.bpe.scope.service.impl.FCScopeInstanceImpl.executeProcess(FCS
> > > copeInstanceImpl.java:392)
> > >         at
> > >
> >
> org.apache.ode.bpe.scope.service.impl.FCScopeInstanceImpl.handleFault(FCScop
> > > eInstanceImpl.java:531)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.processInternalEvent(ProcessInstan
> > > ce.java:287)
> > >         at
> > >
> >
> org.apache.ode.bpe.engine.ProcessInstance.processEvent(ProcessInstance.java:
> > > 209)
> > >         at
> > >
> >
> org.apache.ode.bpe.correlation.CorrelationService.createInstanceAndRoute(Cor
> > > relationService.java:231)
> > >         at
> > >
> >
> org.apache.ode.bpe.correlation.CorrelationService.correlateEvent(Correlation
> > > Service.java:338)
> > >         at
> > >
> >
> org.apache.ode.bpe.bped.unmanaged.EventDirectorSLImpl.sendEvent(EventDirecto
> > > rSLImpl.java:116)
> > >         at
> > > org.apache.servicemix.bpe.BPEEndpoint.process(BPEEndpoint.java:146)
> > >
> > > <snip>
> > >
> > > After do some code diving I came across areas of the code I'd like to
> ask
> > > about:
> > >
> > > 1) FScopeInstanceImpl - the HashMap which contains the faultHandlers
> keyed
> > > by faultType is never actually populated by fault type since the
> > > addFaultHandler method is only called from StartScopeAction which
> > populates
> > > the faultType as "" (and hence the ServiceMix integration layer does not
> > > populate the faultType on the BPRuntimeException). Was this a planned
> > > implementation that never got finished?
> > >
> > > 2) StartCatchAction - this class has commented out code that deals with
> > > faultTypes created on the faultHandler and the creation of an
> Interaction
> > to
> > > hold the faultMessage contents instead of using the straight data
> object.
> > > Was this also an area that was yet to be fully implemented? What was the
> > > intention of the commented out code and was there some caveat with the
> > > approach that was previously being taken?
> > >
> > > I am aware that the majority of work is being done in trunk now as PXE
> and
> > > BPE have been subsumed into ODE now. Any help would be appreciated in
> this
> > > area.
> > >
> > > Kind regards,
> > >
> > > Grant McDonald
> > >
> > >
> >
> >
>
>

Mime
View raw message