Skip to content

A Aliyun MNS producer for Broadway.

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE
Apache-2.0
LICENSE.md
Notifications You must be signed in to change notification settings

edragonconnect/off_broadway_mns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

OffBroadwayMNS

A Aliyun MNS connector for Broadway

Installation

The package can be installed by adding off_broadway_mns to your list of dependencies in mix.exs:

def deps do
  [
    {:off_broadway_mns, "~> 1.0"}
  ]
end

Documentation can be found at https://hexdocs.pm/off_broadway_mns.

Usage

defmodule XXX.Pipeline.MNS do
  use Broadway
  require Logger
  alias Broadway.Message

  def start_link(queue) do
    Broadway.start_link(
      __MODULE__,
      name: __MODULE__,
      producer: [
        module: {
          OffBroadway.MNS.Producer,
          queue: queue
        },
        concurrency: 4
      ],
      processors: [
        default: [
          concurrency: 4,
          min_demand: 16,
          max_demand: 32
        ]
      ],
      batchers: [
        default: [
          concurrency: 2,
          batch_size: 200,
          batch_timeout: 3000
        ]
      ]
    )
  end

  @impl true
  def handle_message(_, message, _) do
    Message.update_data(message, fn data ->
      # update data here
      data
    end)
  end

  @impl true
  def handle_batch(_, messages, _batch_info, _context) do
    Enum.map(messages, fn
      message ->
        # add handle code here
        # if failed return: Message.failed(message, "failed reason")
        message
    end)
  end

  @impl true
  def handle_failed(messages, _context) do
    # add handle code here
    messages
  end
end

About

A Aliyun MNS producer for Broadway.

Resources

License

Apache-2.0, Apache-2.0 licenses found

Licenses found

Apache-2.0
LICENSE
Apache-2.0
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages