我创建了一个.net核心API,它在RabbitMQ队列中推送一条消息.我曾经习惯IOptions从.json文件中读取配置数据并将其添加为依赖项.
以下是我的控制器的代码:
[Route("api/[controller]")]
public class RestController : Controller
{
private RabbitMQConnectionDetail _connectionDetail;
public RestController(IOptions<RabbitMQConnectionDetail> connectionDetail)
{
_connectionDetail = connectionDetail.Value;
}
[HttpPost]
public IActionResult Push([FromBody] OrderItem orderItem)
{
try
{
using (var rabbitMQConnection = new RabbitMQConnection(_connectionDetail.HostName,
_connectionDetail.UserName, _connectionDetail.Password))
{
using (var connection = rabbitMQConnection.CreateConnection())
{
var model = connection.CreateModel();
var helper = new RabbitMQHelper(model, "Topic_Exchange");
helper.PushMessageIntoQueue(orderItem.Serialize(), "Order_Queue");
}
}
}
catch (Exception)
{
return StatusCode((int)HttpStatusCode.BadRequest);
}
return Ok();
}
}
Run Code Online (Sandbox Code Playgroud)
连接详细信息类具有以下属性
public class RabbitMQConnectionDetail
{
public string …Run Code Online (Sandbox Code Playgroud) 我需要运行(安装)一个带有一些自定义参数(参数)的exe
install.exe --no-prompt -u username -p password
Run Code Online (Sandbox Code Playgroud)
上述命令由第 3 方团队提供,用于允许静默安装代理
由于我尝试通过 powershell 安装它,所以我想知道如何传递自定义参数。
注意:此 exe 是第 3 方组件。我可以运行命令来安装带有凭据对象的 exe。但在这种情况下同样不起作用。
I have gone through the documentation and examples of Polly Framework, and it's really awesome and simple to use !!
In my case, I want to classify all the exceptions into 3 types: temporary, permanent and log. Now, I want to have a single piece of code which will be responsible to handle errors which are temporary in nature by doing wait and retry using Polly Framework.
WaitAndRetryAsync(new[]{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(2),
TimeSpan.FromSeconds(5)
})
Run Code Online (Sandbox Code Playgroud)
Same way, if something is permanent in nature …