Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time

Developer FAQ

How to 'log' messages in a third party database ?

Jasmin runs without a database, everything is in-memory and messages are exchanged through AMQP broker (RabbitMQ), if you need to get these messages you have to consume from the right queues as described in :doc:`/messaging/index`.

Here's an example:

Thanks to Pedro's contribution:

Here is the PySQLPool mod to @farirat ´s gist

Here is the code to launch the consumer as a system Daemon in Debian/Ubuntu

1) create jasmind_consumer file in /etc/init.d/
2) chmod a+x
3) Modify the path and script name of your consumer in jasmind_consumer
4) Remember to exec "update-rc.d jasmind_consumer defaults" in order to start at boot


More on this:

.. literalinclude::
   :language: python

How to directly access the Perspective Broker API ?

Management tasks can be done directly when accessing PerspectiveBroker API, it will be possible to:

  • Manage SMPP Client connectors,
  • Check status of all connectors,
  • Send SMS,
  • Manage Users & Groups,
  • Manage Routes (MO / MT),
  • Access statistics,
  • ...

Here's an example:

.. literalinclude::
   :language: python

Can you provide an example of how to use EvalPyFilter ?

Let's say you need your filter to pass only messages from username foo:

if routable.user.username == 'foo':
    result = False
    result = True


Although UserFilter is already there to provide this feature, this is just a simple example of using EvalPyFilter.

So your python script will have a routable global variable, it is an instance of RoutableDeliverSm if you're playing with a MO Route and it will be an instance of RoutableSubmitSm if you're considering it with a MT Route.

In order to implement your specific filter, you have to know all the attributes these objects are providing,

Now let's make an advanced example, the below filter will:

  • Connect to a database
  • Check if the message destination_address is in blacklisted_numbers table
  • Pass only if the destination_address is not blacklisted
.. literalinclude::
   :language: python

How to log events inside an EvalPyFilter ?

It is a usual method to get the filter logging directly to the Router's log file (default is router.log), here's a very simple example of doing it:

.. literalinclude::
   :language: python


More on python logging: here.

How to set an EvalPyFilter for a MT Route ?

I have written my EvalPyFilter, how can i use it to filter MT messages ?

Using jCli:

First, create your filter:

jcli : filter -a
Adding a new Filter: (ok: save, ko: exit)
> type evalpyfilter
> pyCode /some/path/
> fid blacklist_check
> ok
Successfully added Filter [EvalPyFilter] with fid:blacklist_check

Second, create a MT Route:

jcli : mtrouter -a
Adding a new MT Route: (ok: save, ko: exit)
> type StaticMTRoute
jasmin.routing.Routes.StaticMTRoute arguments:
filters, connector, rate
> filters blacklist_check
> connector smppc(SOME-SMSC)
> rate 0.0
> order 10
> ok
Successfully added MTRoute [StaticMTRoute] with order:10

And you're done ! test your filter by sending a SMS through Jasmin's APIs.

PDU params keep resetting to connector defaults even after interception ?

When sending MT messages through httpapi, some pdu parameters will be reset to connector defaults even if they were manually updated inside an interceptor script, how can Jasmin avoid updatingmy pdu params ?

After updating a pdu parameter, it must be locked so Jasmin will not re-update it again, here's an example:

.. literalinclude::
   :language: python


Locking pdu parameters is only needed when message is pushed from httpapi.