Configuring SPADE to connect to another SPADE deployment

This article explains how to connect two SPADE deployments so that they can transfer files between each other.


As this scenario demonstrates transfers between two SPADE deployments you will need two hosts. For simplicity the host on which you've been running the previous scenarios will be referred to as the "shipping" host that will be sending the data and the other one will be referred to as the "receiving" host that will be warehousing the data when it arrives. The model here is that you want to move data from your shipping host and store it in a remote warehouse. These are simply labels as all SPADE deployments are peers so can be interchanged to set up transfers in the opposite direction.

It is assumed that the nest-spade-war project has been install and running as outlined here on both the shipping and receiving hosts, and that the log output of both JBoss servers can be seen in appropriate terminals. It is essential that these deployments have different identities, i.e. different email addresses.

It is also helpful if you have at least read the Local Warehouse scenario in order to familiarize yourself with the concepts discussed there as they will be re-used here. Moreover, as this scenario builds upon the Emailing Confirmations scenario to provide data, you should work through that one first.

Also, as in that scenario, the following environmental variables need to be set on both host. They are show here being set to their standard values.

export JBOSS_HOME=${HOME}/server/jboss-as-7.1.1.Final
export SPADE_VERSION=2.2.0
export SPADE_WAR_HOME=${HOME}/nest-spade-war-${SPADE_VERSION}


You now have two instances of SPADE to configure.

The Shipping Host

To complete the configuration of the shipping host you need to update its ssh configuration and add a new outbound transfer to the spade.xml. The following command, where RECEIVING_HOST has already been set to the receiving host's name and it is assumed you are using the same user id, will do just that.

cat >> ~/.ssh/config << EOF

    User `whoami`
    IdentityFile ~/.ssh/`hostname`_scptransfer

You can now use the following commands to transfer files over to the receiving host using scp accepting the RSA key when asked and using the remote account's password, as the appropriate key is not yet installed on the receiving host.

scp ~/bin/ ~/.ssh/`hostname` ${RECEIVING_HOST}:.

The following XML will declare the new outbound transfer on the shipping host and should be added to the spade.xml file immediately below the existing outboundTransfer, with remote_user@remote_mail_host being replaced by the address you've selected for your remote, i.e. receiving, SPADE instance, receiving_host replaced by the name of the receiving host and shipping_host replaced by the name of the shipping host.

        <name>Transfer to Receiver</name>

You can then set up a registration that uses this new outbound transfer by using the following commands.

mkdir -p ~/spade/registrations/local
cp ${SPADE_WAR_HOME}/src/main/extras/examples/registration.3.xml ~/spade/registrations/local

You can now turn you attention to the receiving host.

The Receiving Host

Assuming that you are starting with a cleanly installed SPADE deployment on the receiving host, you are going to need to set up both the scp and SPADE configruations.

The following commands, where SHIPPING_HOST has already been set to the shipping host's name, sets up the receiving of files from the shipping host, using scp.

mkdir -p ~/spade/receiving/${SHIPPING_HOST}
mkdir -p ~/bin
mv ~/bin
cd ~/.ssh
echo from=\"${SHIPPING_HOST}\",command=\"$HOME/bin/ -d $HOME/spade/receiving/${SHIPPING_HOST}\",\
no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding $PUBLIC_KEY >> authorized_keys
chmod 644 authorized_keys
cd -

The following element should now bebe added to the spade.xml file below the existing warehouse element, with local_user@local_mail_host being replaced by the address you've selected for your local, i.e. shipping, SPADE instance, and shipping_host being replaced with the name of the host shipping the file.

        <name>Transfer From Shipper</name>

Finally you need to set up this host to use email by executing the following commands.

cp ${SPADE_WAR_HOME}/src/main/extras/examples/ ~/spade/
chmod 600 ~/spade/

You will need to edit this file and provide the appropriate information, where the receiving host is considers the be "local" ,for all values enclosed by angle brackets.


Execution of this scenario is similar to the scenario upon which it is built, namely the Emailing Confirmations scenario, except that the commands are now spread between the shipping and receiving hosts. To begin with the following commands should be run on the shipping host.

${JBOSS_HOME}/bin/ --connect --command="deploy \
    --name=spade.war ${SPADE_WAR_HOME}/target/spade-${SPADE_VERSION}.war"
mkdir -p ~/spade/dropbox/mock
cat > ~/spade/dropbox/mock/ << EOF
put some junk in here
touch ~/spade/dropbox/mock/mock.5.tem

Inspect the shipping hosts log file and wait until you see the "finisher" complete. Then execute the following commands on the receiving host.

${JBOSS_HOME}/bin/ --connect --command="deploy \
    --name=spade.war ${SPADE_WAR_HOME}/target/spade-${SPADE_VERSION}.war"
# Wait for the "finisher" for this file to stop, e.g. 5 seconds
sleep 5
find ~/spade/warehouse -name "mock.5.*"

Now make sure the confirmations have been sent and return to the shipping host to execute the following command.


The transfer between two instances of SPADE is now complete.

You should remember that all of the src/main/bash command you have been executing are only to force the examples thropugh the system. Left to itself all of these commands run periodically and you do not need to actively down anyython other than dorp files and their semaphores into the appropriate dropbox.


Having successfully completed this scenario you should now undeploy the application on both hosts using the following command.

${JBOSS_HOME}/bin/ --connect --command="undeploy spade.war"