CLOUDSTACK-9554 Juniper Contrail plug-in is publishing events to wrong message bus

This commit is contained in:
subhash yedugundla 2016-08-17 14:08:53 +05:30 committed by subhash_y
parent 9eb8b2e90b
commit 725ddb82a1
2 changed files with 20 additions and 8 deletions

View File

@ -81,6 +81,17 @@
<artifactId>cloud-framework-events</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-utils</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-framework-spring-lifecycle</artifactId>

View File

@ -28,8 +28,8 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.messagebus.MessageBus;
import org.apache.cloudstack.framework.messagebus.MessageBusBase;
import org.apache.cloudstack.framework.events.EventBus;
import org.apache.cloudstack.framework.events.EventBusException;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
@ -46,7 +46,7 @@ import com.cloud.utils.component.ComponentMethodInterceptor;
public class EventUtils {
private static final Logger s_logger = Logger.getLogger(EventUtils.class);
protected static MessageBus s_messageBus = null;
protected static EventBus s_eventBus = null;
public EventUtils() {
}
@ -58,7 +58,7 @@ public class EventUtils {
}
try {
s_messageBus = ComponentContext.getComponent(MessageBusBase.class);
s_eventBus = ComponentContext.getComponent(EventBus.class);
} catch (NoSuchBeanDefinitionException nbe) {
return; // no provider is configured to provide events bus, so just return
}
@ -72,9 +72,10 @@ public class EventUtils {
eventDescription.put("details", details);
event.setDescription(eventDescription);
try {
s_messageBus.publish(EventTypes.getEntityForEvent(eventType), eventType, null, event);
} catch (Exception e) {
s_logger.warn("Failed to publish action event on the the event bus.");
s_eventBus.publish(event);
} catch (EventBusException evx) {
String errMsg = "Failed to publish contrail event.";
s_logger.warn(errMsg, evx);
}
}