定制 mehr-it/lara-sqs-plain 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mehr-it/lara-sqs-plain

Composer 安装命令:

composer require mehr-it/lara-sqs-plain

包简介

Receive custom/plain SQS messages in Laravel

README 文档

README

Allows to receive custom/plain SQS messages in Laravel. This is very useful if you have to work with third party messages not dispatched from Laravel.

You receive the plain message content in the constructor of your handler classes. You may specify your own handler class for each queue.

This package is based on the mehr-it/lara-sqs-ext package and implements most of it's features.

Installation

composer require mehr-it/lara-sqs-plain

This package uses Laravel's package auto-discovery, so the service provider will be loaded automatically.

Queue configuration

Just configure a queue connection as you would configure any other SQS queue in Laravel. The only difference is the message_handler option, which must be the name of the class which should handle the messages:

'sqs-plain-conn' => [
	'driver'          => 'sqs-plain',
	'key'             => '112233445566778899',
	'secret'          => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
	'prefix'          => 'https://sqs.eu-central-1.amazonaws.com/11223344556677',
	'queue'           => 'msgs',
	'region'          => 'eu-central-1',
	'message_handler' => 'App\\Job\\MyPlainHandler',
],

Long polling

To enable long polling, you may add the option message_wait_timeout to the queue configuration. This sets the WaitTimeSeconds parameter to the configured amount of time.

'message_wait_timeout' => 20,

Message handlers

To create a handler for SQS messages, simply extend the SqsPlainMessageHandler class. The handle function will be invoked for each message and the raw message body will be available in the message attribute:

class MyPlainHandler extends SqsPlainMessageHandler {
	
	public function handle() {
	
		$rawMessage = $this->message;
	}
					
}

The InteractsWithQueue and InteractsWithSqsQueue trait is already implemented in the base class, so you can interact with the queue.

Message handlers my define the same properties as common jobs, to control the job workers. This includes tries, timeout, timeoutAt, automaticQueueVisibility, automaticQueueVisibilityExtra or the retryUntil method.

Thanks

Thanks to Jussi Hamalainen who wrote the jusahah/laravel-sqs-jobless package which served as guideline for this package.

统计信息

  • 总下载量: 187
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固