pip_services_msgdistribution 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new65

Pip.Services Logo
Message Distribution Microservice #

This microservice is distributes messages to one or many recipients using their configured delivery methods: email or sms.

The microservice currently supports the following deployment options:

  • Deployment platforms: Standalone Process, Seneca
  • External APIs: HTTP/REST, Seneca

This microservice has optional dependencies on the following microservices:

Quick Links:

Contract #

Logical contract of the microservice is presented below. For physical implementation (HTTP/REST, Thrift, Seneca, Lambda, etc.), please, refer to documentation of the specific protocol.

class MessageV1 {
  String template;
  String from;
  String cc;
  String bcc;
  String reply_to;
  var subject;
  var text;
  var html;
}

abstract class IMessageDistributionV1 {
  Future sendMessage(String correlationId, RecipientV1 recipient,
      MessageV1 message, ConfigParams parameters, String method);

  Future sendMessages(String correlationId, List<RecipientV1> recipients,
      MessageV1 message, ConfigParams parameters, String method);

  Future sendMessageToRecipient(
      String correlationId,
      String recipientId,
      String subscription,
      MessageV1 message,
      ConfigParams parameters,
      String method);

  Future sendMessageToRecipients(
      String correlationId,
      List<String> recipientIds,
      String subscription,
      MessageV1 message,
      ConfigParams parameters,
      String method);
}

Message can be defined directly or loaded from message template (stored in msgtemplates service);

When message is set directly its subject, text and html content can be set by handlebars template, that it processed using parameters set. Here is an example:

Dear {{ name }},
<p/>
Please, help us to verify your email address. Your verification code is {{ code }}.
<p/>
Click on the 
<a href="{{ clientUrl }}/#/verify_email?server_url={{ serverUrl }}&email={{ email }}&code={{ code }}">link</a>
to complete verification procedure
<p/>
---<br/>
{{ signature }}

Download #

Right now the only way to get the microservice is to check it out directly from github repository

git clone git@github.com:pip-services-users/pip-services-msgdistribution-dart.git

Pip.Service team is working to implement packaging and make stable releases available for your as zip downloadable archieves.

Run #

Add config.yml file to the root of the microservice folder and set configuration parameters. As the starting point you can use example configuration from config.example.yml file. Example of microservice configuration

---
- descriptor: "pip-services-commons:logger:console:default:1.0"
  level: "trace"

- descriptor: "pip-services-msgdistribution:controller:default:default:1.0"
  
- descriptor: "pip-services-msgdistribution:service:http:default:1.0"
  connection:
    protocol: "http"
    host: "0.0.0.0"
    port: 8080

For more information on the microservice configuration see Configuration Guide.

For more information on the microservice configuration see Configuration Guide.

Start the microservice using the command:

dart ./bin/run.dart

Use #

The easiest way to work with the microservice is to use client SDK. The complete list of available client SDKs for different languages is listed in the Quick Links

If you use dart, then get references to the required libraries:

Add pip-services3-commons-dart, pip-services3-rpc-dart and pip-services_msgdistribution packages

import 'package:pip_services3_commons/pip_services3_commons.dart';
import 'package:pip_services3_rpc/pip_services3_rpc.dart';

import 'package:pip_services_msgdistribution/pip_services_msgdistribution.dart';

Instantiate the client and open connection to the microservice

// Create the client instance
var client = MessageDistributionHttpClientV1(config);

// Configure the client
client.configure(httpConfig);

// Connect to the microservice
try{
  await client.open(null)
}catch() {
  // Error handling...
}       
// Work with the microservice
// ...

Now the client is ready to perform operations

// Send email message to users
var recipient1 = RecipientV1(id: '1', email: 'user1@somewhere.com', phone: '+1234567890');
var recipient2 = RecipientV1(id: '2', email: 'user2@somewhere.com', phone: '+0987654321');
var message = MessageV1(subject: 'Test', 
                             text: 'This is a test message. Please, ignore it');
await client.sendMessages(
    null,
    [
        recipient1,
        recipient2
    ],
    message,
    null,
    DeliveryMethod.All
);

Acknowledgements #

This microservice was created and currently maintained by

  • Sergey Seroukhov
  • Nuzhnykh Egor.

1.0.0 #

  • Initial version

example/README.md

Examples for Message Distribution Microservice #

This microservice is distributes messages to one or many recipients using their configured delivery methods: email or sms.

Define configuration parameters that match the configuration of the microservice's external API

// Service/Client configuration
var httpConfig = ConfigParams.fromTuples(
	"connection.protocol", "http",
	"connection.host", "localhost",
	"connection.port", 8080
);

Instantiate the service

controller = MessageDistributionController();
controller.configure(ConfigParams());

service = MessageDistributionHttpServiceV1();
service.configure(httpConfig);

var references = References.fromTuples([
    Descriptor('pip-services-email', 'controller', 'default',
        'default', '1.0'),
    controller,
    Descriptor(
        'pip-services-email', 'service', 'http', 'default', '1.0'),
    service
]);

controller.setReferences(references);
service.setReferences(references);

await service.open(null);

Instantiate the client and open connection to the microservice

// Create the client instance
var client = MessageDistributionHttpClientV1(config);

// Configure the client
client.configure(httpConfig);

// Connect to the microservice
try{
  await client.open(null)
}catch() {
  // Error handling...
}       
// Work with the microservice
// ...

Now the client is ready to perform operations

// Send email message to users
var recipient1 = RecipientV1(id: '1', email: 'user1@somewhere.com', phone: '+1234567890');
var recipient2 = RecipientV1(id: '2', email: 'user2@somewhere.com', phone: '+0987654321');
var message = MessageV1(subject: 'Test', 
                             text: 'This is a test message. Please, ignore it');
await client.sendMessages(
    null,
    [
        recipient1,
        recipient2
    ],
    message,
    null,
    DeliveryMethod.All
);

In the help for each class there is a general example of its use. Also one of the quality sources are the source code for the tests.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pip_services_msgdistribution: ^1.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pip_services_msgdistribution/pip_services_msgdistribution.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
97
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 6, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13

Analysis suggestions

Package not compatible with SDK flutter

Because it is not compatible with any of the supported runtimes: flutter-native, flutter-web

Package not compatible with runtime flutter-native on android

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime flutter-native on ios

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime flutter-native on linux

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime flutter-native on macos

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime flutter-native on windows

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime flutter-web on web

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime native-aot

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Package not compatible with runtime web

Because of the import of dart:mirrors via the import chain package:pip_services_msgdistribution/pip_services_msgdistribution.dartpackage:pip_services_msgdistribution/src/container/container.dartpackage:pip_services_msgdistribution/src/container/MessageDistributionProcess.dartpackage:pip_services_msgdistribution/src/build/MessageDistributionServiceFactory.dartpackage:pip_services_msgdistribution/src/services/version1/MessageDistributionHttpServiceV1.dartpackage:pip_services3_rpc/pip_services3_rpc.dartpackage:pip_services3_rpc/src/build/build.dartpackage:pip_services3_rpc/src/build/DefaultRpcFactory.dartpackage:pip_services3_rpc/src/services/StatusRestService.dartpackage:pip_services3_rpc/src/services/RestService.dartpackage:pip_services3_rpc/src/services/HttpResponseSender.dartpackage:pip_services3_commons/pip_services3_commons.dartpackage:pip_services3_commons/src/validate/validate.dartpackage:pip_services3_commons/src/validate/ProjectionParamsSchema.dartpackage:pip_services3_commons/src/validate/ArraySchema.dartpackage:pip_services3_commons/src/reflect/ObjectReader.dartpackage:pip_services3_commons/src/reflect/PropertyReflector.dartdart:mirrors

Maintenance suggestions

The description is too long. (-3 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.1
pip_clients_email ^1.0.0 1.0.0
pip_clients_emailsettings ^1.0.0 1.0.2
pip_clients_msgtemplates ^1.0.0 1.0.0
pip_clients_smssettings ^1.0.0 1.0.1
pip_services3_commons ^1.0.9 1.0.11
pip_services3_components ^1.0.6 1.0.6
pip_services3_container >=1.0.3 <2.0.0 1.0.3
pip_services3_data ^1.0.5 1.0.6
pip_services3_grpc ^1.0.0 1.0.0
pip_services3_mongodb ^1.0.4 1.0.4
pip_services3_rpc ^1.0.3 1.0.7
pip_services_email ^1.0.0 1.0.1
pip_services_emailsettings ^1.0.0 1.0.1
pip_services_msgtemplates ^1.0.0 1.0.0
pip_services_smssettings ^1.0.0 1.0.0
Transitive dependencies
angel_container 1.1.0
angel_framework 2.1.1
angel_http_exception 1.1.0
angel_model 1.0.3
angel_route 3.1.0+1
async 2.4.2
bson 0.3.2
charcode 1.1.3
code_buffer 1.0.1
collection 1.14.13
combinator 1.1.0
convert 2.1.1
crypto 2.1.5
dart2_constant 1.0.2+dart2
file 5.2.1
fixnum 0.10.11
googleapis_auth 0.2.12
grpc 2.2.0
http2 1.0.0
http_parser 3.1.4
http_server 0.9.8+3
intl 0.16.1
logging 0.11.4
mailer 3.0.4
matcher 0.12.8
merge_map 1.0.2
meta 1.2.1
mime 0.9.6+3
mock_request 1.0.7
mongo_dart 0.4.0
mongo_dart_query 0.4.1
more 1.18.2 2.5.0
mustache4dart2 0.1.0
path 1.7.0
pedantic 1.9.1
pip_clients_activities 1.0.0
pip_services_activities 1.0.2
pool 1.4.0
protobuf 1.0.1
quiver 2.1.3
quiver_hashcode 2.0.0
recase 2.0.1 3.0.0
source_span 1.7.0
sprintf 4.0.2
stack_trace 1.9.5
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.3
typed_data 1.2.0
uuid 2.2.0
yaml 2.2.1
Dev dependencies
test >=1.14.2 <2.0.0