You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by madhuv <mv...@advisorsoftware.com> on 2009/02/19 21:44:14 UTC

Problem deploying Service Unit for a custom component

Hi all,

I am new to servicemix. I am using SMX 3.3 in a standalone mode. I have
written some SUs for a few of the available components like servicemix-file
and servicemix-bean and they work fine.

Now I want to write my own service engine and deploy a SU for it. My test
code for the SE is very simple. The actual code for the transform method
doesn't seem to matter, I have tried several variations.

/**
 * @org.apache.xbean.XBean element = "driver"
 */

public class MASDriver extends TransformComponentSupport {
	private static final Logger log = Logger.getLogger(MASDriver.class);

	public MASDriver() {
		super();
		log.info("MASDriver called");
	}

	public MASDriver(QName service, String endpoint) {
		super(service, endpoint);
		log.info("MASDriver service endpoint called");
	}


	@Override
    protected boolean transform(MessageExchange me, NormalizedMessage in,
NormalizedMessage out) throws MessagingException {
            int total = 10000;
            Random rand = new Random();
            log.info("Start generating messages: " +
System.currentTimeMillis());

            for (int i = 0; i < total; i++) {
                    StringSource source = new
StringSource(String.valueOf(rand.nextDouble() + i + 1));
                    out.setContent(source);
                    InOnly outExchange =
getExchangeFactory().createInOnlyExchange();
                    outExchange.setInMessage(out);
                    getDeliveryChannel().sendSync(outExchange);
                    outExchange.setStatus(ExchangeStatus.DONE);
                    }
            log.info("End generating messages:: " +
System.currentTimeMillis());
            return false;
    }
} 

I have no errors when I install and start this SE in servicemix. 

Next, I created an SU for it, which contains only an xbean.xml file...

<?xml version="1.0" encoding="UTF-8"?>

<beans  xmlns:myse="http://asi.org/config/1.0" xmlns:asi="asi">
<myse:driver   service="asi:driver" 
				  endpoint="endpoint" >
</myse:driver>
</beans>


When I deploy this service-unit into SMX, it gives me this error. 

DEBUG - DeploymentService              - Unpack service unit archive
D:\DEV\serviceMix\apache-servicemix-3.3\data\smx\service-assemblies\asi-mas\version_2\install\driver-su.zip
to D:\DEV\serviceMix\ap
ache-servicemix-3.3\data\smx\service-assemblies\asi-mas\version_2\sus\masdriver-se\driver-su
[Fatal Error] :1:1: Content is not allowed in prolog.



There is no other exception or error in the log, but the result is that my
endpoint is not activated. What am I missing? 
Thanks for any help or tips to solving this problem.
-- 
View this message in context: http://www.nabble.com/Problem-deploying-Service-Unit-for-a-custom-component-tp22109295p22109295.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem deploying Service Unit for a custom component

Posted by Gert Vanthienen <ge...@gmail.com>.
L.S.,

First of all, I would like to point you to this FAQ entry
http://servicemix.apache.org/should-i-create-my-own-jbi-components.html.
 Creating your own binding component only makes sense if you require
the use of some kind of protocol that isn't already supported by
ServiceMix or Camel.  If your goal is to add some custom code to the
ESB, you're probably better off staying with the servicemix-bean
component for that.

Because this is such a rare use case, we probably don't have a
tutorial/wiki page that really describes how to do this step by step.
However, if you think you have a use case for it, your best bet is
probably to look at one of the existing components to find out what
else you need to implement.  Here you just created one endpoint, but
you'd also have to create the component itself and configure the XBean
plugin to generate the XSD for your endpoints.  You can have a look at
e.g. the servicemix-vfs component and the components-pom parent for
code examples and the correct plugin configuration.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/2/19 madhuv <mv...@advisorsoftware.com>:
>
> Hi all,
>
> I am new to servicemix. I am using SMX 3.3 in a standalone mode. I have
> written some SUs for a few of the available components like servicemix-file
> and servicemix-bean and they work fine.
>
> Now I want to write my own service engine and deploy a SU for it. My test
> code for the SE is very simple. The actual code for the transform method
> doesn't seem to matter, I have tried several variations.
>
> /**
>  * @org.apache.xbean.XBean element = "driver"
>  */
>
> public class MASDriver extends TransformComponentSupport {
>        private static final Logger log = Logger.getLogger(MASDriver.class);
>
>        public MASDriver() {
>                super();
>                log.info("MASDriver called");
>        }
>
>        public MASDriver(QName service, String endpoint) {
>                super(service, endpoint);
>                log.info("MASDriver service endpoint called");
>        }
>
>
>        @Override
>    protected boolean transform(MessageExchange me, NormalizedMessage in,
> NormalizedMessage out) throws MessagingException {
>            int total = 10000;
>            Random rand = new Random();
>            log.info("Start generating messages: " +
> System.currentTimeMillis());
>
>            for (int i = 0; i < total; i++) {
>                    StringSource source = new
> StringSource(String.valueOf(rand.nextDouble() + i + 1));
>                    out.setContent(source);
>                    InOnly outExchange =
> getExchangeFactory().createInOnlyExchange();
>                    outExchange.setInMessage(out);
>                    getDeliveryChannel().sendSync(outExchange);
>                    outExchange.setStatus(ExchangeStatus.DONE);
>                    }
>            log.info("End generating messages:: " +
> System.currentTimeMillis());
>            return false;
>    }
> }
>
> I have no errors when I install and start this SE in servicemix.
>
> Next, I created an SU for it, which contains only an xbean.xml file...
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <beans  xmlns:myse="http://asi.org/config/1.0" xmlns:asi="asi">
> <myse:driver   service="asi:driver"
>                                  endpoint="endpoint" >
> </myse:driver>
> </beans>
>
>
> When I deploy this service-unit into SMX, it gives me this error.
>
> DEBUG - DeploymentService              - Unpack service unit archive
> D:\DEV\serviceMix\apache-servicemix-3.3\data\smx\service-assemblies\asi-mas\version_2\install\driver-su.zip
> to D:\DEV\serviceMix\ap
> ache-servicemix-3.3\data\smx\service-assemblies\asi-mas\version_2\sus\masdriver-se\driver-su
> [Fatal Error] :1:1: Content is not allowed in prolog.
>
>
>
> There is no other exception or error in the log, but the result is that my
> endpoint is not activated. What am I missing?
> Thanks for any help or tips to solving this problem.
> --
> View this message in context: http://www.nabble.com/Problem-deploying-Service-Unit-for-a-custom-component-tp22109295p22109295.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>