Package org.apache.synapse.message.store

Examples of org.apache.synapse.message.store.MessageStore


     *                   Message store
     */
    public void modifyMessageStore(String xml) throws AxisFault {
        try {
            OMElement msElem = createElement(xml);
            MessageStore messageStore =
                    MessageStoreFactory.createMessageStore(msElem, new Properties());

            if(messageStore == null) {
                String message = "Unable to edit the message Store. Error in the configuration";
                handleException(log,message,null);
            }


            SynapseConfiguration configuration = getSynapseConfiguration();
            MessageStore oldMessageStore = configuration.getMessageStore(messageStore.getName());
            if(oldMessageStore != null) {
                // this means there is an existing message store

                //1st we clean up the old
                configuration.removeMessageStore(oldMessageStore.getName());
                oldMessageStore.destroy();

                // then we startup the new.
                String fileName = oldMessageStore.getFileName();
                messageStore.setFileName(fileName);
                messageStore.init(getSynapseEnvironment());
                configuration.addMessageStore(messageStore.getName(),messageStore);
                MediationPersistenceManager mp = getMediationPersistenceManager();
                mp.saveItem(messageStore.getName(),ServiceBusConstants.ITEM_TYPE_MESSAGE_STORE);
View Full Code Here


    public String getMessageStore(String name) throws AxisFault {
        SynapseConfiguration configuration = getSynapseConfiguration();

        assert configuration != null;
        MessageStore store = configuration.getMessageStore(name);
        if (store != null) {

        } else {
            handleException(log, "Message Store " + name + " does not exist", null);
        }
View Full Code Here

    public void deleteMessageStore(String name) throws AxisFault {
        SynapseConfiguration configuration = getSynapseConfiguration();

        assert configuration != null;
        if (configuration.getMessageStore(name) != null) {
            MessageStore removedMessageStore = configuration.getMessageStore(name);
            configuration.removeMessageStore(name);
            String fileName = removedMessageStore.getFileName();
            removedMessageStore.destroy();

            MediationPersistenceManager pm = getMediationPersistenceManager();
            pm.deleteItem(removedMessageStore.getName(),
                    fileName,ServiceBusConstants.ITEM_TYPE_MESSAGE_STORE);

        } else {
            handleException(log, "Message Store " + name + " does not exist", null);
        }
View Full Code Here

     * @return number of message stores in the given store
     * @throws AxisFault if Message store does not exists
     */
    public int getSize(String name) throws AxisFault {

        MessageStore store = getMessageStoreImpl(name);
        if (store != null) {
            return store.size();
        } else {
            handleException(log, "Message Store " + name + " does not exist !!!", null);
        }

        //This code block will never reach as handleException method will always returns a Exception
View Full Code Here

     * @return implementation class name of the Message Store
     * @throws AxisFault
     */
    public String getClassName(String name) throws AxisFault {

        MessageStore store = getMessageStoreImpl(name);

        if (store != null) {
            return store.getClass().getName();
        } else {
            handleException(log, "Message Store " + name + " does not exist !!!", null);
        }

        //This code block will never reach as handleException method will always returns a Exception
View Full Code Here

     * @return Array of details of the All Messages in store
     * @throws AxisFault
     */
    public MessageInfo[] getAllMessages(String name) throws AxisFault {

        MessageStore store = getMessageStoreImpl(name);
        if (store != null) {

            List<MessageContext> messageContexts = store.getAll();
            List<MessageInfo> messageInfoList = new ArrayList<MessageInfo>();

            for (MessageContext mc : messageContexts) {
                MessageInfo info = createMessageInfo(mc);
                if (info != null) {
View Full Code Here

     * @return Array of Message information for a given page
     * @throws AxisFault
     */
    public MessageInfo[] getPaginatedMessages(String name, int pageNumber)
            throws AxisFault {
        MessageStore store = getMessageStoreImpl(name);
        if (store != null) {
            int itemsPerPageInt = MSGS_PER_PAGE;
            int numberOfPages = (int) Math.ceil((double) store.size() / itemsPerPageInt);

            if(numberOfPages == 0) {
                numberOfPages = 1;
            }
            if (pageNumber > numberOfPages - 1) {
                pageNumber = numberOfPages - 1;
            }

            int startIndex = (pageNumber * itemsPerPageInt);
            int endIndex = ((pageNumber + 1) * itemsPerPageInt);

            List<MessageInfo> paginatedMsgList = new ArrayList<MessageInfo>();
            for (int i = startIndex; i < endIndex && i < store.size(); i++) {

                MessageInfo info = createMessageInfo(store.get(i));

                if (info != null) {
                    paginatedMsgList.add(info);
                }
            }
View Full Code Here

            throws AxisFault {

        SynapseConfiguration configuration = getSynapseConfiguration();

        assert configuration != null;
        MessageStore store = configuration.getMessageStore(name);

        if (store != null) {
            MessageContext synCtx = store.get(messageId);
            if (synCtx != null) {
                return synCtx.getEnvelope().toString();
            } else {
                handleException(log, "Message with id " + messageId + " Does not exist", null);
            }
View Full Code Here

        return null;
    }

    public void deleteAllMessages(String name) throws AxisFault {

        MessageStore store = getMessageStoreImpl(name);

        if (store != null) {
            store.clear();
        } else {
            handleException(log, "Message Store " + name + " does not exist", null);
        }
    }
View Full Code Here

            log.debug("Message Store Deployment from file : " + fileName + " : Started");
        }

        try{

            MessageStore ms = MessageStoreFactory.createMessageStore(artifactConfig,properties);
            if(ms != null) {
                ms.setFileName((new File(fileName)).getName());
                 if (log.isDebugEnabled()) {
                    log.debug("Message Store named '" + ms.getName()
                            + "' has been built from the file " + fileName);
                }
                ms.init(getSynapseEnvironment());
                if (log.isDebugEnabled()) {
                    log.debug("Initialized the Message Store : " + ms.getName());
                }
                getSynapseConfiguration().addMessageStore(ms.getName(), ms);
                if (log.isDebugEnabled()) {
                    log.debug("Message Store Deployment from file : " + fileName + " : Completed");
                }
                log.info("Message Store named '" + ms.getName()
                        + "' has been deployed from file : " + fileName);
                return ms.getName();
            } else {
                handleSynapseArtifactDeploymentError("Message Store Deployment from the file : "
                    + fileName + " : Failed. The artifact " +
                        "described in the file  is not a Message Store");
            }
View Full Code Here

TOP

Related Classes of org.apache.synapse.message.store.MessageStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.