[ 
https://issues.apache.org/jira/browse/AMQ-3692?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14278518#comment-14278518
 ] 

metatech commented on AMQ-3692:
-------------------------------

Here is a workaround that allows to use the Blueprint XBean syntax, with 
"blueprint.aries.xml-validation:=false".
I did not find how to enhance the validator to allow it yet.
{code}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
           
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0";
           
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
           xmlns:amq="http://activemq.apache.org/schema/core";
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
           xsi:schemaLocation="
                http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                http://activemq.apache.org/schema/core 
http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd";
        >
    <manifest>
        Bundle-SymbolicName: activemq-broker.xml; 
blueprint.aries.xml-validation:=false
    </manifest>

    <broker>
    
        <shutdownHooks>
            <bean class="org.apache.activemq.util.osgi.BrokerBundleWatcher"  
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
                <property name="bundleContext" ref="blueprintBundleContext"/>
            </bean>
        </shutdownHooks>

    </broker>
</blueprint>
{code}

Without it, the error is the following in ServiceMix 4.5.3 : 

{code}
Unable to start blueprint container for bundle activemq-broker.xml
org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to 
validate xml
        at org.apache.aries.blueprint.container.Parser.validate(Parser.java:288)
        at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:281)
        at 
org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:230)
        at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching 
wildcard is strict, but no declaration can be found for element 'bean'.
{code}



> ActiveMQ OSGi bundle should be stopped when broker stops itself
> ---------------------------------------------------------------
>
>                 Key: AMQ-3692
>                 URL: https://issues.apache.org/jira/browse/AMQ-3692
>             Project: ActiveMQ
>          Issue Type: New Feature
>          Components: Broker
>    Affects Versions: 5.4.2
>         Environment: ServiceMix 4.3
>            Reporter: metatech
>            Assignee: Hiram Chirino
>             Fix For: 5.9.0
>
>         Attachments: BrokerBundleWatcher.patch, BrokerBundleWatcher_v2.patch, 
> BrokerBundleWatcher_v3.patch, BrokerService.patch, activemq-broker.xml
>
>
> In case of error, the ActiveMQ broker can stop itself.
> In an OSGi/Blueprint environment, the bundle is however still in 
> Active/Created state, which misleads an external monitoring software into 
> thinking that the broker is running fine.
> This patch stops the bundle when the broker stops itself.
> This patch can also auto-restart the bundle, which will restart the broker.
> This is critical in an Master/Slave configuration : when the connection to 
> the database is lost, the broker cannot maintain the DB exclusive lock, and 
> it stops itself.  The bundle should be stopped and started again, so that it 
> enters again the "Creating" state, in which it waits to obtain the DB lock 
> again.
> The class "BrokerBundleWatcher" needs to be registered with the 
> "shutdownHooks" property of the ActiveMQ "BrokerService".  However, there is 
> a limitation with the XBean syntax in a Blueprint XML, which does not allow 
> to define inner beans.  The workaround is to define the "activemq-broker.xml" 
> in full native Blueprint syntax (no XBean).
> The patch also provides a modified version of the BrokerService, that injects 
> its own reference into the ShutdownHook's which implement the 
> "BrokerServiceAware" interface.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to