Tabnine Logo
ManagementHelper
Code IndexAdd Tabnine to your IDE (free)

How to use
ManagementHelper
in
org.apache.activemq.artemis.api.core.management

Best Java code snippets using org.apache.activemq.artemis.api.core.management.ManagementHelper (Showing top 20 results out of 315)

origin: wildfly/wildfly

/**
* Returns the result of an operation invocation or an attribute value.
* <br>
* If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}.
* and the result will be a String corresponding to the server exception.
*/
public static Object getResult(final ICoreMessage message) throws Exception {
 return getResult(message, null);
}
origin: wildfly/wildfly

/**
* Stores an operation invocation in a message to invoke the corresponding operation the value from the server resource.
*
* @param message       message
* @param resourceName  the name of the resource
* @param operationName the name of the operation to invoke on the resource
* @see ResourceNames
*/
public static void putOperationInvocation(final ICoreMessage message,
                     final String resourceName,
                     final String operationName) throws Exception {
 ManagementHelper.putOperationInvocation(message, resourceName, operationName, (Object[]) null);
}
origin: wildfly/wildfly

/**
* Returns whether the invocation of the management operation on the server resource succeeded.
*/
public static boolean hasOperationSucceeded(final Message message) throws JMSException {
 return ManagementHelper.hasOperationSucceeded(JMSManagementHelper.getCoreMessage(message));
}
origin: apache/activemq-artemis

protected Object invokeSyncOperation(final String resourceName,
                  final String operationName,
                  final Object... parameters) throws Exception {
 ClientMessage message = clientSession.createMessage(false);
 ManagementHelper.putOperationInvocation(message, resourceName, operationName, parameters);
 ClientMessage reply;
 try {
   reply = requestor.request(message, 3000);
 } catch (Exception e) {
   throw new IllegalStateException("Exception while invoking " + operationName + " on " + resourceName, e);
 }
 if (reply == null) {
   throw new IllegalStateException("no reply received when invoking " + operationName + " on " + resourceName);
 }
 if (!ManagementHelper.hasOperationSucceeded(reply)) {
   throw new IllegalStateException("operation failed when invoking " + operationName +
                    " on " +
                    resourceName +
                    ": " +
                    ManagementHelper.getResult(reply));
 }
 return ManagementHelper.getResult(reply);
}
origin: apache/activemq-artemis

private Integer getQueueID(ClientSession session, SimpleString queueName) throws Exception {
 Integer queueID = -1;
 Object result;
 try (ClientRequestor requestor = new ClientRequestor(session, "activemq.management")) {
   ClientMessage managementMessage = session.createMessage(false);
   ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queueName, "ID");
   session.start();
   logger.debug("Requesting ID for: " + queueName);
   ClientMessage reply = requestor.request(managementMessage);
   result = ManagementHelper.getResult(reply);
 }
 if (result != null && result instanceof Number) {
   queueID = ((Number) result).intValue();
 }
 return queueID;
}
origin: apache/activemq-artemis

@Test
public void testHandleManagementMessageWithUnknownAttribute() throws Exception {
 Configuration config = createBasicConfig().setJMXManagementEnabled(false);
 ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
 server.start();
 // invoke attribute and operation on the server
 ICoreMessage message = new CoreMessage(1, 100);
 ManagementHelper.putAttribute(message, ResourceNames.BROKER, "started");
 ICoreMessage reply = server.getManagementService().handleMessage(message);
 Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
 Assert.assertTrue((Boolean) ManagementHelper.getResult(reply));
}
origin: wildfly/wildfly

/**
* Returns whether the JMS message corresponds to the result of a management attribute value.
*/
public static boolean isAttributesResult(final Message message) {
 return !ManagementHelper.isOperationResult(message);
}
origin: apache/activemq-artemis

@Test
public void testHandleManagementMessageWithOperation() throws Exception {
 String queue = RandomUtil.randomString();
 String address = RandomUtil.randomString();
 Configuration config = createBasicConfig().setJMXManagementEnabled(false);
 ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
 server.start();
 // invoke attribute and operation on the server
 CoreMessage message = new CoreMessage(1, 100);
 ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "createQueue", queue, address);
 Message reply = server.getManagementService().handleMessage(message);
 Assert.assertTrue(ManagementHelper.hasOperationSucceeded(reply));
}
origin: wildfly/wildfly

/**
* Returns the result of an operation invocation or an attribute value.
* <br>
* If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}.
* and the result will be a String corresponding to the server exception.
*/
public static Object[] getResults(final Message message) throws Exception {
 return ManagementHelper.getResults(JMSManagementHelper.getCoreMessage(message));
}
origin: wildfly/wildfly

/**
* Stores a resource attribute in a JMS message to retrieve the value from the server resource.
*
* @param message      JMS message
* @param resourceName the name of the resource
* @param attribute    the name of the attribute
* @throws JMSException if an exception occurs while putting the information in the message
* @see org.apache.activemq.artemis.api.core.management.ResourceNames
*/
public static void putAttribute(final Message message,
                final String resourceName,
                final String attribute) throws JMSException {
 ManagementHelper.putAttribute(JMSManagementHelper.getCoreMessage(message), resourceName, attribute);
}
origin: wildfly/wildfly

/**
* Returns whether the JMS message corresponds to the result of a management attribute value.
*/
public static boolean isAttributesResult(final Message message) throws JMSException {
 return ManagementHelper.isAttributesResult(JMSManagementHelper.getCoreMessage(message));
}
origin: apache/activemq-artemis

public Object invokeOperation(final Class desiredType,
               final String operationName,
               final Object... args) throws Exception {
 try (ClientSessionFactory sessionFactory = locator.createSessionFactory();
    ClientSession session = getSession(sessionFactory);
    ClientRequestor requestor = getClientRequestor(session)) {
   ClientMessage m = session.createMessage(false);
   ManagementHelper.putOperationInvocation(m, resourceName, operationName, args);
   ClientMessage reply = requestor.request(m);
   if (reply != null) {
    if (ManagementHelper.hasOperationSucceeded(reply)) {
      return ManagementHelper.getResult(reply, desiredType);
    } else {
      throw new Exception((String) ManagementHelper.getResult(reply));
    }
   } else {
    return null;
   }
 }
}
origin: apache/activemq-artemis

ManagementHelper.putAttribute(managementMessage, ResourceNames.QUEUE + queue, "ID");
managementSession.start();
if (logger.isDebugEnabled()) {
Number idObject = (Number) ManagementHelper.getResult(reply);
queueID = idObject.longValue();
origin: apache/activemq-artemis

@Test
public void testHandleManagementMessageWithKnownAttribute() throws Exception {
 Configuration config = createBasicConfig().setJMXManagementEnabled(false);
 ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
 server.start();
 // invoke attribute and operation on the server
 ICoreMessage message = new CoreMessage(1, 100);
 ManagementHelper.putAttribute(message, ResourceNames.BROKER, "attribute.Does.Not.Exist");
 ICoreMessage reply = server.getManagementService().handleMessage(message);
 Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
 Assert.assertNotNull(ManagementHelper.getResult(reply));
}
origin: wildfly/wildfly

/**
* Returns whether the JMS message corresponds to the result of a management operation invocation.
*/
public static boolean isOperationResult(final Message message) throws JMSException {
 return ManagementHelper.isOperationResult(JMSManagementHelper.getCoreMessage(message));
}
origin: wildfly/wildfly

/**
* Returns the result of an operation invocation or an attribute value.
* <br>
* If an error occurred on the server, {@link #hasOperationSucceeded(Message)} will return {@code false}.
* and the result will be a String corresponding to the server exception.
*/
public static Object getResult(final ICoreMessage message, Class desiredType) throws Exception {
 Object[] res = ManagementHelper.getResults(message);
 if (res != null) {
   return JsonUtil.convertJsonValue(res[0], desiredType);
 } else {
   return null;
 }
}
origin: apache/activemq-artemis

/**
* Stores a resource attribute in a JMS message to retrieve the value from the server resource.
*
* @param message      JMS message
* @param resourceName the name of the resource
* @param attribute    the name of the attribute
* @throws JMSException if an exception occurs while putting the information in the message
* @see org.apache.activemq.artemis.api.core.management.ResourceNames
*/
public static void putAttribute(final Message message,
                final String resourceName,
                final String attribute) throws JMSException {
 ManagementHelper.putAttribute(JMSManagementHelper.getCoreMessage(message), resourceName, attribute);
}
origin: apache/activemq-artemis

/**
* Returns whether the JMS message corresponds to the result of a management attribute value.
*/
public static boolean isAttributesResult(final Message message) throws JMSException {
 return ManagementHelper.isAttributesResult(JMSManagementHelper.getCoreMessage(message));
}
origin: apache/activemq-artemis

@Test
public void testHandleManagementMessageWithOperationWhichFails() throws Exception {
 Configuration config = createBasicConfig().setJMXManagementEnabled(false);
 ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, false));
 server.start();
 // invoke attribute and operation on the server
 CoreMessage message = new CoreMessage(1, 100);
 ManagementHelper.putOperationInvocation(message, ResourceNames.BROKER, "thereIsNoSuchOperation");
 ICoreMessage reply = server.getManagementService().handleMessage(message);
 Assert.assertFalse(ManagementHelper.hasOperationSucceeded(reply));
 Assert.assertNotNull(ManagementHelper.getResult(reply));
}
origin: wildfly/wildfly

/**
* Stores an operation invocation in a JMS message to invoke the corresponding operation the value from the server resource.
*
* @param message       JMS message
* @param resourceName  the name of the resource
* @param operationName the name of the operation to invoke on the resource
* @throws JMSException if an exception occurs while putting the information in the message
* @see org.apache.activemq.artemis.api.core.management.ResourceNames
*/
public static void putOperationInvocation(final Message message,
                     final String resourceName,
                     final String operationName) throws JMSException {
 try {
   ManagementHelper.putOperationInvocation(JMSManagementHelper.getCoreMessage(message), resourceName, operationName);
 } catch (Exception e) {
   throw JMSManagementHelper.convertFromException(e);
 }
}
org.apache.activemq.artemis.api.core.managementManagementHelper

Javadoc

Helper class to use ActiveMQ Artemis Core messages to manage server resources.

Most used methods

  • getResult
    Returns the result of an operation invocation or an attribute value. If an error occurred on the ser
  • putOperationInvocation
    Stores an operation invocation in a message to invoke the corresponding operation the value from the
  • hasOperationSucceeded
    Returns whether the invocation of the management operation on the server resource succeeded.
  • putAttribute
    Stores a resource attribute in a message to retrieve the value from the server resource.
  • getResults
    Returns the result of an operation invocation or an attribute value. If an error occurred on the ser
  • isOperationResult
    Returns whether the JMS message corresponds to the result of a management operation invocation.
  • isAttributesResult
    Returns whether the JMS message corresponds to the result of a management attribute value.
  • retrieveOperationParameters
    Used by ActiveMQ Artemis management service.
  • storeResult
    Used by ActiveMQ Artemis management service.

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSharedPreferences (Context)
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Permission (java.security)
    Legacy security code; do not use.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now